@RequestMapping(value = "/edit/{id}", method = RequestMethod.GET) public ModelAndView editCemeteryPage(@PathVariable Integer id) { ModelAndView modelAndView = new ModelAndView("edit-cemetery-form"); Cemetery cemetery = cemeteryService.getResource(id); modelAndView.addObject("cemetery", cemetery); return modelAndView; }
@RequestMapping(value = "/delete/{id}", method = RequestMethod.GET) public ModelAndView deleteCemetery(@PathVariable Integer id) { ModelAndView modelAndView = new ModelAndView("home"); cemeteryService.deleteResource(id); String message = "Cemetery was successfully deleted."; modelAndView.addObject("message", message); return modelAndView; }
@ResponseBody @RequestMapping(value = "/list", method = RequestMethod.GET, produces = "application/json") public List<Cemetery> listOfCemeterys() { ModelAndView modelAndView = new ModelAndView("list-of-cemeterys"); List<Cemetery> cemeterys = cemeteryService.getResources(); modelAndView.addObject("cemeterys", cemeterys); return cemeterys; }
@RequestMapping(value = "/add", method = RequestMethod.POST) public ModelAndView addingCemetery(@ModelAttribute Cemetery cemetery) { ModelAndView modelAndView = new ModelAndView("home"); cemeteryService.addResource(cemetery); String message = "Cemetery was successfully added."; modelAndView.addObject("message", message); return modelAndView; }
@RequestMapping(value = "/edit/{id}", method = RequestMethod.POST) public ModelAndView edditingCemetery( @ModelAttribute Cemetery cemetery, @PathVariable Integer id) { ModelAndView modelAndView = new ModelAndView("home"); cemeteryService.updateResource(cemetery); String message = "Cemetery was successfully edited."; modelAndView.addObject("message", message); return modelAndView; }