コード例 #1
0
 // delete a paymentCard
 @RequestMapping(value = "{id}", method = RequestMethod.DELETE)
 public String delete(@PathVariable Long id, Model model) {
   paymentCardService.deletePaymentCardById(id);
   String message = "Succesfully deleted Payment Card.";
   FlashMap.setSuccessMessage(message);
   return "redirect:../cards/";
 }
コード例 #2
0
 // update a paymentCard
 @RequestMapping(method = RequestMethod.POST)
 public String update(@Valid PaymentCard paymentCard, BindingResult bindingResult, Model model) {
   if (bindingResult.hasErrors()) {
     List<String> types = paymentCardService.getTypes();
     model.addAttribute("typeList", types);
     return "cards/edit";
   }
   paymentCardService.updatePaymentCard(paymentCard);
   String message = "Succesfully updated Payment Card " + paymentCard.getNumber() + ".";
   FlashMap.setSuccessMessage(message);
   return "redirect:/cards/" + paymentCard.getId();
 }
コード例 #3
0
 // add a paymentCard
 @RequestMapping(method = RequestMethod.PUT)
 public String add(
     @Valid PaymentCard paymentCard,
     BindingResult bindingResult,
     Principal currentUser,
     Model model) {
   if (bindingResult.hasErrors()) {
     List<String> types = paymentCardService.getTypes();
     model.addAttribute("typeList", types);
     return "cards/add";
   }
   if (currentUser != null) {
     paymentCardService.addPaymentCard(paymentCard, currentUser.getName());
     String message = "Succesfully added Payment Card " + paymentCard.getNumber() + ".";
     FlashMap.setSuccessMessage(message);
     return "redirect:/cards/" + paymentCard.getId();
   } else {
     // TODO: return error
     return "redirect:/cards/add";
   }
 }