Exemple #1
0
 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;
 }
Exemple #2
0
        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));
        }
Exemple #3
0
        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);
        }