package ems.controller;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.SessionAttributes;

import ems.service.TodoService;

@Controller
@SessionAttributes("name")
public class TodoController {
    @Autowired
    private TodoService mTodoService;

    @RequestMapping(value = "/list-todos", method = RequestMethod.GET)
    public String showTodosList(ModelMap model) {
        String user = (String) model.get("name");
        model.addAttribute("todos", mTodoService.retrieveTodos(user));
        return "list-todos";
    }

    @RequestMapping(value = "/add-todo", method = RequestMethod.GET)
    public String showTodoPage() {
        return "todo";
    }

    @RequestMapping(value = "/add-todo", method = RequestMethod.POST)
    public String addTodo(ModelMap model, @RequestParam String desc) {
        mTodoService.addTodo((String) model.get("name"), desc, new Date(), false);
        model.clear();
        return "redirect:/list-todos";
    }
}

@@ -1307,11 +1307,219 @@
 %22;%0A    %7D
+%0A%0A    @RequestMapping(value = %22/delete-todo%22, method = RequestMethod.GET)%0A    public String deleteTodo(@RequestParam int id) %7B%0A        mTodoService.deleteTodo(id);%0A        return %22redirect:/list-todos%22;%0A    %7D
 %0A%7D%0A

Add delete method to TodoController