Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -249,5 +249,12 @@ public String updateUserProfile(@RequestParam("userid") int userid,@RequestParam
}
return "redirect:index";
}

@GetMapping("customers/delete")
public String deleteCustomer(@RequestParam("id") int id) {
userService.deleteUser(id);
return "redirect:/admin/customers";
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,13 @@ public User getUserByUsername(String username) {
return null;
}
}
@Transactional
public void deleteUser(int id) {
Session session = sessionFactory.getCurrentSession();
User user = session.get(User.class, id);
if (user != null) {
session.delete(user);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ public boolean checkUserExists(String username) {
public User getUserByUsername(String username) {
return userDao.getUserByUsername(username);
}
public void deleteUser(int id) {
userDao.deleteUser(id);
}

}
8 changes: 8 additions & 0 deletions JtProject/src/main/webapp/views/displayCustomers.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@
${customer.address}

</td>
<td>
<a href="/admin/customers/delete?id=${customer.id}"
class="btn btn-danger btn-sm"
onclick="return confirm('Are you sure you want to delete this customer?');">
Delete
</a>
</td>

</tr>
</c:forEach>

Expand Down
Loading