public async Task <IActionResult> UpdateUser(int id, UserUpdateDm userForUpdate) { if (id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value)) { return(Unauthorized()); } var userFromRepo = await _repository.GetUser(id); var userToSave = _mapper.MapDmToEm(userForUpdate, userFromRepo); if (await _repository.SaveAll()) { return(NoContent()); } throw new Exception($"Updating user {id} failed on save."); }
public User MapDmToEm(UserUpdateDm userUpdateDm, User userFromRepo) { return(_autoMapper.Map(userUpdateDm, userFromRepo)); }