From c111d4d93ad6b106f81067b9d98b05d4a0e6164c Mon Sep 17 00:00:00 2001 From: sankalp7654 Date: Tue, 21 Jan 2020 02:05:55 +0530 Subject: [PATCH] minor bug fixes --- .../springboot/web/controller/TodoController.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/sansoft/springboot/web/controller/TodoController.java b/src/main/java/com/sansoft/springboot/web/controller/TodoController.java index 87992ad..ce4f11b 100644 --- a/src/main/java/com/sansoft/springboot/web/controller/TodoController.java +++ b/src/main/java/com/sansoft/springboot/web/controller/TodoController.java @@ -44,13 +44,13 @@ public void InitBinder(WebDataBinder binder) { @RequestMapping(value = "/list-todos", method = RequestMethod.GET) public String showTodos(ModelMap model) { - String name = getLoggedInUserName(model); + String name = getLoggedInUserName(); model.put("name", name); - model.put("list", service.retrieveTodos("in28Minutes")); + model.put("list", service.retrieveTodos(getLoggedInUserName())); return "list-todos"; } - private String getLoggedInUserName(ModelMap model) { + private String getLoggedInUserName() { Object principal = SecurityContextHolder.getContext() .getAuthentication().getPrincipal(); @@ -62,7 +62,7 @@ private String getLoggedInUserName(ModelMap model) { @RequestMapping(value = "/add-todo", method = RequestMethod.GET) public String showAddTodoPage(ModelMap model) { - model.addAttribute("todo", new Todo(0, getLoggedInUserName(model), "Default Desc", + model.addAttribute("todo", new Todo(0, getLoggedInUserName(), "Default Desc", new Date(), false)); return "todo"; } @@ -73,7 +73,7 @@ public String addATodo(ModelMap model, @Valid Todo todo, BindingResult result) { return "todo"; } - service.addTodo(getLoggedInUserName(model), todo.getDesc(), todo.getTargetDate(), false); + service.addTodo(getLoggedInUserName(), todo.getDesc(), todo.getTargetDate(), false); model.put("list", service.retrieveTodos("in28Minutes")); return "redirect:/list-todos"; } @@ -87,7 +87,7 @@ public String updateTodo(@RequestParam int id, ModelMap model) { @RequestMapping(value="/update-todo", method=RequestMethod.POST) public String showUpdateTodoPage(@Valid Todo todo, BindingResult result, ModelMap model) { - todo.setUser(getLoggedInUserName(model)); + todo.setUser(getLoggedInUserName()); if(result.hasErrors()) { return "todo"; }