@RequestMapping(value = "/list", method = RequestMethod.GET)
 public String todoList(Model model, Integer offset, Integer maxResults) {
   model.addAttribute("todoList", toDoItemService.getPageList(offset, maxResults));
   model.addAttribute("count", toDoItemService.count());
   model.addAttribute("offset", offset);
   return "/todo-list";
 }
  @RequestMapping(value = "/list/delete", method = RequestMethod.GET)
  public String delete(@RequestParam(value = "itemId", required = true) Integer id, Model model) {

    ToDoItem userDeleted = toDoItemService.get(id);
    toDoItemService.delete(userDeleted);
    return "redirect:/list";
  }
 @RequestMapping(value = "/list/notDoneList", method = RequestMethod.GET)
 public String notDoneList(Model model, Integer offset, Integer maxResults) {
   model.addAttribute(
       "notDoneList", toDoItemService.findByStatus(Status.NOT_DONE, offset, maxResults));
   model.addAttribute("count", toDoItemService.count());
   model.addAttribute("offset", offset);
   return "/not-done-list";
 }
 @RequestMapping(value = "/list/performedList", method = RequestMethod.GET)
 public String performedList(Model model, Integer offset, Integer maxResults) {
   model.addAttribute(
       "performedList", toDoItemService.findByStatus(Status.PERFORMED, offset, maxResults));
   model.addAttribute("count", toDoItemService.count());
   model.addAttribute("offset", offset);
   return "/performed-list";
 }
 @RequestMapping(
     value = {"/list/edit"},
     method = RequestMethod.GET)
 public String editItemForm(
     @RequestParam(value = "itemId", required = true) Integer id, Model model) {
   ToDoItem toDoItem = toDoItemService.get(id);
   model.addAttribute("itemEdit", toDoItem);
   model.addAttribute("categories", categoryService.getAll());
   return "/edit-todo-item";
 }
  @RequestMapping(value = "/editItem", method = RequestMethod.POST)
  public String editItem(
      @ModelAttribute("itemEdit") ToDoItem toDoItem,
      BindingResult result,
      HttpServletRequest request) {

    toDoItem.setId(Integer.parseInt(request.getParameter("OldItemId")));
    toDoItem.setCategory(categoryService.get(Integer.parseInt(request.getParameter("category"))));
    toDoItemService.update(toDoItem);
    return "redirect:/list";
  }
  @RequestMapping(value = "/addItem", method = RequestMethod.POST)
  public String addItem(
      @ModelAttribute("todoItem") ToDoItem todoItem,
      BindingResult result,
      HttpServletRequest request) {

    Category category = categoryService.get(Integer.parseInt(request.getParameter("category")));
    todoItem.setCategory(category);
    toDoItemService.add(todoItem);

    return "redirect:/list";
  }