public ActionResult DeleteUser(int id) { LibraryManagementSystemContext context = new LibraryManagementSystemContext(); UsersRepository usersRepository = new UsersRepository(context); UsersDeleteUserVM model = new UsersDeleteUserVM(); User user = usersRepository.GetByID(id); model.ID = user.ID; model.FullName = user.ToString(); return View(model); }
public ActionResult DeleteUser(UsersDeleteUserVM model) { LibraryManagementSystemContext context = new LibraryManagementSystemContext(); UsersRepository usersRepository = new UsersRepository(context); User user = usersRepository.GetAll(filter: u => u.ID == model.ID, includeProperties: "Roles").FirstOrDefault(); if (user == null) { return HttpNotFound(); } user.Roles = null; usersRepository.Delete(user); return RedirectToAction("Index", "Users"); }