listUsers = userService.getAllUsers();
+ model.addAttribute("listUsers", listUsers);
+
return "admin";
}
+ @GetMapping("/deleteEmployee/{id}")
+ public String deleteEmployee(@PathVariable (value = "id") long id) {
+
+ // call delete employee method
+ this.userService.deleteUserById(id);
+ return "redirect:/admin";
+ }
+
+ @GetMapping("/showFormForUpdate/{id}")
+ public String showFormForUpdate(@PathVariable ( value = "id") long id, Model model) {
+
+ User user = userService.getUserById(id);
+
+ model.addAttribute("user",user);
+ return "update_user";
+ }
+ @PostMapping("/saveUser")
+ public String saveUser(@ModelAttribute("employee") User user) {
+ // save employee to database
+ userService.saveUser(user);
+ return "redirect:/";
+ }
+
+
+
+
}
diff --git a/src/main/resources/templates/admin.html b/src/main/resources/templates/admin.html
index c96d10d..7e2b6fe 100644
--- a/src/main/resources/templates/admin.html
+++ b/src/main/resources/templates/admin.html
@@ -37,9 +37,26 @@
-
-
The good shit
- Welcome Admin
-
+
+
+
+ | # |
+ FirstName |
+ LastName |
+ Email |
+
+
+
+
+ |
+ |
+ |
+ |
+ Update
+ Delete
+ |
+
+
+