public async Task <IActionResult> EditLawyerAccount(LawyerDto lawyerDto, IFormFile file) { if (ModelState.IsValid) { string userId = lawyerDto.AppUserId.ToString(); var user = await _userManager.FindByIdAsync(userId); if (user == null) { ViewBag.ErrorMessage = $"User with Id = { userId } can not be found"; return(View("Not Found")); } else { user.Email = lawyerDto.Email; user.UserName = lawyerDto.UserName; var result = await _userManager.UpdateAsync(user); if (result.Succeeded) { await _lawyerService.EditLawyerAccount(lawyerDto, file); return(RedirectToAction("EditLawyer", "Lawyer", new { @id = lawyerDto.LawyerId })); } foreach (var error in result.Errors) { ModelState.AddModelError("", error.Description); } } } return(View()); }