public async Task <IActionResult> EditAccount([FromForm] ClientEditAccountViewModel model) { if (!ModelState.IsValid) { return(BadRequest()); } var user_identity = await _userManager.FindByIdAsync(model.UserId); user_identity.Email = model.Email; user_identity.UserName = model.Username; var result = await _userManager.UpdateAsync(user_identity); Guid clientIdGuid = Guid.Empty; if (!Guid.TryParse(model.UserId, out clientIdGuid)) { throw new Exception("Invalid Guid Format"); } clientsService.EditAccount(clientIdGuid, model.FirstName, model.LastName, model.PhoneNo); return(Redirect(Url.Action("Index", "Admins"))); }
public async Task <IActionResult> EditAccount() { var userId = _userManager.GetUserId(User); var user_identity = await _userManager.FindByIdAsync(userId); var user_email = await _userManager.GetEmailAsync(user_identity); var user_username = await _userManager.GetUserNameAsync(user_identity); var client = clientsService.GetClientById(userId); ClientEditAccountViewModel clientEditAccountViewModel = new ClientEditAccountViewModel { UserId = userId, FirstName = client.FirstName, LastName = client.LastName, PhoneNo = client.PhoneNo, Email = user_email, Username = user_username }; return(View(clientEditAccountViewModel)); }