[HttpPost]
public async Task<IActionResult> Edit(UserDTO model)
{
AppUser user = await _userManager.FindByNameAsync(User.Identity.Name);
if (ModelState.IsValid)
{
user = mapper.Map<AppUser>(model);
if (model.Password != null)
{
user.PasswordHash = _passwordHasher.HashPassword(user, model.Password);
}
IdentityResult result = await _userManager.UpdateAsync(user);
if (result.Succeeded)
{
uow.SaveChange();
await _signInManager.SignOutAsync();
return Redirect("/Account/Login");
}
else
{
foreach (var item in result.Errors)
{
ModelState.AddModelError("", item.Description);
}
}
}
return View(user);
}