public async Task <ActionResult> DeleteUser(string ID) { AppUser user = await UserManager.FindByIdAsync(ID); if (user == null) { ViewBag.Error = $"Error occurred while looking for a user with ID = {ID}"; return(View("Error")); } TempData["Message"] = new Message() { Text = "Success! <strong>You have successfully deleted user.</strong>", ClassName = "alertMessage successful" }; //First delete book from shelf ShelfRepository.RemoveBooksFromUser(ID); if (user.UserName == User.Identity.Name) { AuthManager.SignOut(); await UserManager.DeleteAsync(user); return(RedirectToAction("List", "Book")); } await UserManager.DeleteAsync(user); return(RedirectToAction("Index", "Admin")); }