public IActionResult Edit() { AccountEditViewModel viewModel = new AccountEditViewModel { Message = (string)TempData["Message"] }; return(View(viewModel)); }
public IActionResult Edit(AccountEditViewModel viewModel) { if (!ModelState.IsValid) { return(View(viewModel)); } if (authenticationBusinessLogic.VerifyPassword(ApplicationUser.Password, viewModel.OldPassword)) { ModelState.AddModelError(nameof(AccountEditViewModel.OldPassword), "Old password is incorrect."); return(View(viewModel)); } ApplicationUser.Password = authenticationBusinessLogic.HashPassword(viewModel.NewPassword); ApplicationUser.Save(Database.Connection); TempData["Message"] = "Account saved successfully."; return(RedirectToAction(nameof(Edit))); }