This commit is contained in:
Le Deng
2017-03-08 15:30:53 -05:00
parent 4bd11ae1e8
commit c6504d3616
4 changed files with 106 additions and 54 deletions

View File

@@ -43,8 +43,40 @@ public class PaymentResource {
userService.updateUserBilling(userBilling, userPayment, user);
return new ResponseEntity("Payment Added(Updated) Successfully!", HttpStatus.OK);
}
@RequestMapping("/update")
public ResponseEntity updateCreditCard(
@RequestBody String id, Principal principal,
Model model
) {
User user = userService.findByUsername(principal.getName());
UserPayment userPayment = userPaymentService.findById(Long.parseLong(id));
if (user.getId()!=userPayment.getUser().getId()) {
return new ResponseEntity("Invalid Request", HttpStatus.BAD_REQUEST);
} else {
model.addAttribute("user", user);
UserBilling userBilling = userPayment.getUserBilling();
model.addAttribute("userPayment", userPayment);
model.addAttribute("userBilling", userBilling);
List<String> stateList = USConstants.listOfUSStatesCode;
Collections.sort(stateList);
model.addAttribute("stateList", stateList);
model.addAttribute("addNewCreditCard", true);
model.addAttribute("classActiveBilling", true);
model.addAttribute("listOfShippingAddresses", true);
model.addAttribute("userPaymentList", user.getUserPaymentList());
model.addAttribute("userShippingList", user.getUserShippingList());
model.addAttribute("orderList", user.getOrderList());
return new ResponseEntity("Payment Added(Updated) Successfully!", HttpStatus.OK);
}
}
@RequestMapping(value = "/remove", method = RequestMethod.POST)