public async Task <IActionResult> AdminDeleteUser(string userId) { //don't allow a demo user to delete an account var currentLoggedInUser = await userManager.GetUserAsync(User); var demoAdminEmail = _configuration["Data:DemoAdminUser:Email"]; if (currentLoggedInUser.Email == demoAdminEmail) { ViewBag.Message = "Demo user not allowed to delete account."; return(View("Error")); } //make sure user ID is valid var userToDelete = await userManager.FindByIdAsync(userId); if (userToDelete == null) { return(NotFound()); } //find the username for this ID AdminDeleteUserViewModel model = new AdminDeleteUserViewModel(); model.UserId = userId; var username = await userManager.GetUserNameAsync(userToDelete); model.UserName = username; return(View("AdminDeleteUserConfirm", model)); }
//GET public async Task <IActionResult> AdminDeleteUserConfirm(AdminDeleteUserViewModel model) { //don't allow a demo user to delete an account var currentLoggedInUser = await userManager.GetUserAsync(User); var demoAdminEmail = _configuration["Data:DemoAdminUser:Email"]; if (currentLoggedInUser.Email == demoAdminEmail) { ViewBag.Message = "Demo user not allowed to delete account."; return(View("Error")); } return(View(model)); }