// GET: User/Details/5 public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } var user = await _userManager.FindByIdAsync(id.ToString()); if (user == null) { return(NotFound()); } var model = new UserViewVM() { Id = user.Id, Email = user.Email, UserName = user.UserName, FirstName = user.FirstName, LastName = user.LastName }; return(View(model)); }
public async Task <IActionResult> Delete(string id) { var user = await _userManager.FindByIdAsync(id); var model = new UserViewVM { UserName = user.UserName, Id = user.Id }; if (user == null) { throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); } return(View(model)); }
public async Task <IActionResult> Delete(UserViewVM model) { var user = await _userManager.FindByIdAsync(model.Id.ToString()); if (user == null) { throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); } else { var result = await _userManager.DeleteAsync(user); if (result.Succeeded) { return(RedirectToAction("Index")); } } return(View()); }