@RequestMapping(value = "/user/label-list", method = RequestMethod.GET) public ModelAndView listLabel( final HttpServletRequest request, final HttpServletResponse response) { Model model = new ExtendedModelMap(); model.addAttribute("activeMenu", "offer-link"); try { model.addAttribute("offerLabelList", offerManager.getAllOfferLabels()); } catch (KUException e) { log.error(e.getMessage(), e); model.addAttribute("offerLabelList", new ArrayList<OfferLabel>()); saveError(request, e.getMessage()); } return new ModelAndView("/ku/offer-label-list", model.asMap()); }
@RequestMapping(value = "/user/edit-label", method = RequestMethod.GET) public ModelAndView showOfferLabelUpdate( final HttpServletRequest request, final HttpServletResponse response) { String labelId = request.getParameter("labelId"); Model model = new ExtendedModelMap(); model.addAttribute("activeMenu", "offer-link"); try { model.addAttribute("offerLabel", offerManager.getOfferLabelById(Long.parseLong(labelId))); } catch (KUException e) { log.error(e.getMessage(), e); model.addAttribute("offerLabel", new Offer()); saveError(request, e.getMessage()); } return new ModelAndView("/ku/offer-label", model.asMap()); }
@RequestMapping(value = "/user/add-label", method = RequestMethod.POST) @ModelAttribute public ModelAndView addLabel( OfferLabel offerLabel, BindingResult errors, final HttpServletRequest request, final HttpServletResponse response) { Model model = new ExtendedModelMap(); try { offerLabel = offerManager.saveOfferLabel(offerLabel); model.addAttribute("offerLabel", offerLabel); } catch (KUException e) { e.printStackTrace(); model.addAttribute("offerLabel", offerLabel); } model.addAttribute("activeMenu", "offer-link"); return new ModelAndView("/ku/offer-label", model.asMap()); }
@RequestMapping(value = "/user/add-coupon", method = RequestMethod.POST) @ModelAttribute public ModelAndView addCoupon( @ModelAttribute("offer") Offer offer, BindingResult errors, final HttpServletRequest request, final HttpServletResponse response) { Model model = new ExtendedModelMap(); try { log.info("adding coupon :: " + offer.getOfferTitle()); offer = offerManager.saveOffer(offer); model.addAttribute("offer", offer); log.info("coupon added"); model.addAttribute("activeMenu", "offer-link"); model.addAttribute("offerList", offerManager.getAllOffers()); saveMessage(request, "coupon added successfully"); } catch (KUException e) { e.printStackTrace(); saveError(request, "problem in adding coupon"); model.addAttribute("offer", offer); } model.addAttribute("activeMenu", "offer-link"); return new ModelAndView("/ku/coupon-list", model.asMap()); }