diff --git a/bookstore-api/.idea/workspace.xml b/bookstore-api/.idea/workspace.xml index 9db61b3..26696f8 100644 --- a/bookstore-api/.idea/workspace.xml +++ b/bookstore-api/.idea/workspace.xml @@ -19,14 +19,26 @@ - - + + - + + + + + + + + + + + + + @@ -49,7 +61,7 @@ - + @@ -134,6 +146,7 @@ @@ -930,12 +943,12 @@ - + - @@ -998,14 +1011,6 @@ - - - - - - - - @@ -1328,22 +1333,6 @@ - - - - - - - - - - - - - - - - @@ -1352,5 +1341,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bookstore-api/src/main/java/com/bookstore/resource/PaymentResource.java b/bookstore-api/src/main/java/com/bookstore/resource/PaymentResource.java new file mode 100644 index 0000000..fb02180 --- /dev/null +++ b/bookstore-api/src/main/java/com/bookstore/resource/PaymentResource.java @@ -0,0 +1,63 @@ +package com.bookstore.resource; + +import com.bookstore.domain.User; +import com.bookstore.domain.UserBilling; +import com.bookstore.domain.UserPayment; +import com.bookstore.service.UserService; +import com.bookstore.utility.USConstants; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.security.Principal; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; + +/** + * Created by z00382545 on 3/8/17. + */ + +@RestController +@RequestMapping("/payment") +public class PaymentResource { + + @Autowired + private UserService userService; + + @RequestMapping("/listOfCreditCards") + public String listOfCreditCards( + Model model, Principal principal, HttpServletRequest request + ) { + User user = userService.findByUsername(principal.getName()); + model.addAttribute("user", user); + model.addAttribute("userPaymentList", user.getUserPaymentList()); + model.addAttribute("userShippingList", user.getUserShippingList()); + model.addAttribute("orderList", user.getOrderList()); + + + model.addAttribute("listOfCreditCards", true); + model.addAttribute("classActiveBilling", true); + model.addAttribute("listOfShippingAddresses", true); + + return "myProfile"; + } + + @RequestMapping(value = "/add", method = RequestMethod.POST) + public ResponseEntity addNewCreditCardPost( + @RequestBody HashMap mapper, + Principal principal, Model model) { + User user = userService.findByUsername(principal.getName()); + UserPayment userPayment = (UserPayment) mapper.get("userPayment"); + UserBilling userBilling = (UserBilling) mapper.get("userBilling"); + + userService.updateUserBilling(userBilling, userPayment, user); + + return new ResponseEntity("Payment Added(Updated) Successfully!", HttpStatus.OK); + + + } +} diff --git a/store-front/src/app/components/my-profile/my-profile.component.html b/store-front/src/app/components/my-profile/my-profile.component.html index 8100d86..0d0c027 100644 --- a/store-front/src/app/components/my-profile/my-profile.component.html +++ b/store-front/src/app/components/my-profile/my-profile.component.html @@ -159,7 +159,7 @@
- +
diff --git a/store-front/src/app/components/my-profile/my-profile.component.ts b/store-front/src/app/components/my-profile/my-profile.component.ts index aaf8aa7..cbd2811 100644 --- a/store-front/src/app/components/my-profile/my-profile.component.ts +++ b/store-front/src/app/components/my-profile/my-profile.component.ts @@ -31,7 +31,9 @@ export class MyProfileComponent implements OnInit { private user: User = new User(); private userPayment: UserPayment = new UserPayment(); - private userBilling: UserBilling = new UserBilling(); + private userBilling: UserBilling = new UserBilling(); + private userPaymentList: UserPayment[] = []; + private stateList: string[] = []; constructor (private loginService: LoginService, private userService: UserService, private router: Router){ } @@ -102,11 +104,15 @@ export class MyProfileComponent implements OnInit { res => { console.log(res.json()); this.user=res.json(); + this.userPaymentList = this.user.userPaymentList; }, error => { console.log(error); } ); + for (let s in AppConst.usStates) { + this.stateList.push(s); + } } } diff --git a/store-front/src/app/constants/app-const.ts b/store-front/src/app/constants/app-const.ts index 76931c1..c50dd40 100644 --- a/store-front/src/app/constants/app-const.ts +++ b/store-front/src/app/constants/app-const.ts @@ -1,3 +1,76 @@ -export class AppConst { +export class AppConst implements OnInit { public static serverPath='http://127.0.0.1:8181'; + + public static usStates = { + "AL": "Alabama", + "AK": "Alaska", + "AS": "American Samoa", + "AZ": "Arizona", + "AR": "Arkansas", + "CA": "California", + "CO": "Colorado", + "CT": "Connecticut", + "DE": "Delaware", + "DC": "District Of Columbia", + "FM": "Federated States Of Micronesia", + "FL": "Florida", + "GA": "Georgia", + "GU": "Guam", + "HI": "Hawaii", + "ID": "Idaho", + "IL": "Illinois", + "IN": "Indiana", + "IA": "Iowa", + "KS": "Kansas", + "KY": "Kentucky", + "LA": "Louisiana", + "ME": "Maine", + "MH": "Marshall Islands", + "MD": "Maryland", + "MA": "Massachusetts", + "MI": "Michigan", + "MN": "Minnesota", + "MS": "Mississippi", + "MO": "Missouri", + "MT": "Montana", + "NE": "Nebraska", + "NV": "Nevada", + "NH": "New Hampshire", + "NJ": "New Jersey", + "NM": "New Mexico", + "NY": "New York", + "NC": "North Carolina", + "ND": "North Dakota", + "MP": "Northern Mariana Islands", + "OH": "Ohio", + "OK": "Oklahoma", + "OR": "Oregon", + "PW": "Palau", + "PA": "Pennsylvania", + "PR": "Puerto Rico", + "RI": "Rhode Island", + "SC": "South Carolina", + "SD": "South Dakota", + "TN": "Tennessee", + "TX": "Texas", + "UT": "Utah", + "VT": "Vermont", + "VI": "Virgin Islands", + "VA": "Virginia", + "WA": "Washington", + "WV": "West Virginia", + "WI": "Wisconsin", + "WY": "Wyoming" +} + constructor () { + console.log("test"); + for (let s in this.usStates) { + this.stateList.push(s); + console.log(s); + } + } + + ngOnInit() { + + } } \ No newline at end of file diff --git a/store-front/src/app/services/payment.service.spec.ts b/store-front/src/app/services/payment.service.spec.ts new file mode 100644 index 0000000..114ec06 --- /dev/null +++ b/store-front/src/app/services/payment.service.spec.ts @@ -0,0 +1,16 @@ +/* tslint:disable:no-unused-variable */ + +import { TestBed, async, inject } from '@angular/core/testing'; +import { PaymentService } from './payment.service'; + +describe('PaymentService', () => { + beforeEach(() => { + TestBed.configureTestingModule({ + providers: [PaymentService] + }); + }); + + it('should ...', inject([PaymentService], (service: PaymentService) => { + expect(service).toBeTruthy(); + })); +}); diff --git a/store-front/src/app/services/payment.service.ts b/store-front/src/app/services/payment.service.ts new file mode 100644 index 0000000..ff5cdbd --- /dev/null +++ b/store-front/src/app/services/payment.service.ts @@ -0,0 +1,14 @@ +import { Injectable } from '@angular/core'; +import {AppConst} from '../constants/app-const'; +import {Http, Headers} from '@angular/http'; + +@Injectable() +export class PaymentService { + private serverPath:string = AppConst.serverPath; + + constructor(private http:Http) { } + + getUserPaymentlist() { + + } +} \ No newline at end of file