public void MapUserToUpdateRequestToAppUserEntity(UserToUpdateRequest source, ref AppUser destination) { destination.Email = source.Email; destination.UserName = source.UserName; destination.Description = source.Description; destination.City = source.City; destination.FirstName = source.FirstName; destination.LastName = source.LastName; destination.BirthDate = source.BirthDate; }
public async Task <IActionResult> UpdateProfile([FromBody] UserToUpdateRequest user, CancellationToken cancellationToken) { var identifier = User.GetUserId(); var command = new UpdateProfileCommand { User = user, UserId = identifier }; var updatedUser = await _mediator.Send(command, cancellationToken); return(Ok(updatedUser)); }
private async Task <AppUser> MapAndUpdateAsync(AppUser userEntity, UserToUpdateRequest userToUpdate) { _mapper.MapUserToUpdateRequestToAppUserEntity(userToUpdate, ref userEntity); await _userRepo.UpdateAsync(userEntity); if (!await _userRepo.SaveAllAsync()) { throw new DatabaseException("Error occured while updating database."); } var userToReturn = new UserDetailResponse(); return(userEntity); }