@RequestMapping(value = "delete", method = RequestMethod.GET) public String delete(@RequestParam("id") int id) { try { service.delete(id); } catch (NotFoundException e) { e.printStackTrace(); } return "redirect:/menu"; }
@RequestMapping(value = "/update", method = RequestMethod.GET) public String editForUpdate(Model model, @RequestParam("id") int id) { try { model.addAttribute("menuMeal", service.get(id)); } catch (NotFoundException e) { e.printStackTrace(); } return "menuMealEdit"; }
@RequestMapping(value = "/buy", method = RequestMethod.GET) public String editForBuy( Model model, @RequestParam("id") int id, @RequestParam("menuId") int menuId) { Meal meal = new Meal(); MenuMeal menuMeal = new MenuMeal(); try { menuMeal = service.get(id); } catch (NotFoundException e) { e.printStackTrace(); } meal.setDescription(menuMeal.getDescription()); meal.setCost(menuMeal.getCost()); model.addAttribute("meal", meal); model.addAttribute("menuId", menuId); model.addAttribute("userList", userService.getAll()); return "/mealEdit"; }
@RequestMapping(method = RequestMethod.POST) public String createOrUpdate(@ModelAttribute("menuMeal") MenuMeal menuMeal) { service.save(menuMeal); return "redirect:/menu"; }