@RequestMapping( value = {"/expense-category-list"}, method = RequestMethod.GET) public String listPage(Model model) { model.addAttribute("expenseCategory", new ExpenseCategory()); model.addAttribute("allExpenseCategorys", expenseCategoryService.getAll()); return "pages/expense-category/expense-category-list"; }
@RequestMapping(value = "/expense-category/update", method = RequestMethod.POST) public String update( @ModelAttribute("edit") ExpenseCategory expenseCategory, final RedirectAttributes redirectAttributes) { if (expenseCategoryService.edit(expenseCategory) != null) { redirectAttributes.addFlashAttribute("edit", "success"); } else { redirectAttributes.addFlashAttribute("edit", "unsuccess"); } return "redirect:/expense-category-list"; }
@RequestMapping(value = "/expense-category/{operation}/{empId}", method = RequestMethod.GET) public String editRemove( @PathVariable("operation") String operation, @PathVariable("empId") Long id, final RedirectAttributes redirectAttributes, Model model) { if (operation.equals("delete")) { if (expenseCategoryService.delete(id)) { redirectAttributes.addFlashAttribute("deletion", "success"); } else { redirectAttributes.addFlashAttribute("deletion", "unsuccess"); } } else if (operation.equals("edit")) { ExpenseCategory edit = expenseCategoryService.find(id); if (edit != null) { model.addAttribute("edit", edit); return "pages/expense-category/expense-category-form-edit"; } else { redirectAttributes.addFlashAttribute("status", "notfound"); } } return "redirect:/expense-category-list"; }
@RequestMapping( value = {"/expense-category/save"}, method = RequestMethod.POST) public String save( @ModelAttribute("expenseCategory") ExpenseCategory expenseCategory, final RedirectAttributes redirectAttributes) { if (expenseCategoryService.save(expenseCategory) != null) { redirectAttributes.addFlashAttribute("save", "success"); } else { redirectAttributes.addFlashAttribute("save", "unsuccess"); } return "redirect:/expense-category-save"; }