public async Task<ActionResult> EditAccount(EditViewModel model) { if (ModelState.IsValid) { var user = await UserManager.FindByNameAsync(User.Identity.GetUserName()); user.FirstName = model.FirstName; user.LastName = model.LastName; user.Telephone = model.Telephone; var result = await UserManager.UpdateAsync(user); if (result.Succeeded) { return this.RedirectToAction("Login"); } else { result.Errors.ToList().ForEach(err => ModelState.AddModelError(string.Empty, err)); } } return PartialView(model); }
public async Task<ActionResult> EditAccount() { var user = await UserManager.FindByNameAsync(@User.Identity.GetUserName()); System.Diagnostics.Debug.Assert(user != null, "user not found"); var model = new EditViewModel { FirstName = user.FirstName, LastName = user.LastName, Telephone = user.Telephone }; return PartialView(model); }