Skip to content

Commit

Permalink
fix: PUT profile (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
thanhpt1110 authored Nov 21, 2024
1 parent 2efdc8f commit 79a5012
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public interface IProfileService
Task<List<ProfileDto>> GetAllProfilesAsync(ProfileSearchQueryDto query);
Task<ProfileDto> GetProfileByIdAsync(Guid userId);
Task<ProfileDto> CreatProfileAsync(ProfileRequestDto request);
Task<ProfileDto> UpdateProfileAsync(Guid userId, ProfileDto request);
Task<ProfileDto> UpdateProfileAsync(Guid userId, ProfileRequestDto request);

}
}
6 changes: 4 additions & 2 deletions src/ChitChat.Application/Services/ProfileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public async Task<ProfileDto> CreatProfileAsync(ProfileRequestDto request)
_mapper.Map(userApplication, response);
return response;
}
public async Task<ProfileDto> UpdateProfileAsync(Guid userId, ProfileDto request)
public async Task<ProfileDto> UpdateProfileAsync(Guid userId, ProfileRequestDto request)
{
if (userId.ToString() != _claimService.GetUserId())
{
Expand All @@ -79,7 +79,9 @@ public async Task<ProfileDto> UpdateProfileAsync(Guid userId, ProfileDto request
userProfile.SearchData = this.GenerateSearchData(request.DisplayName, userApplication.Email ?? "", userId.ToString());
await _profileRepository.UpdateAsync(userProfile);
await _userRepository.UpdateAsync(userApplication);
return request;
var response = _mapper.Map<ProfileDto>(userProfile);
_mapper.Map(userApplication, response);
return response;
}
private string GenerateSearchData(string displayName, string email, string userId)
{
Expand Down
2 changes: 1 addition & 1 deletion src/ChitChat.WebAPI/Controllers/ProfileController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public async Task<IActionResult> CreatProfileeAsync([FromBody] ProfileRequestDto
[HttpPut]
[Route("${userId}")]
[AllowAnonymous]
public async Task<IActionResult> GetProfileByIdAsync(Guid userId, [FromBody] ProfileDto Profile)
public async Task<IActionResult> GetProfileByIdAsync(Guid userId, [FromBody] ProfileRequestDto Profile)
{
return Ok(ApiResult<ProfileDto>.Success(await _profileService.UpdateProfileAsync(userId, Profile)));
}
Expand Down

0 comments on commit 79a5012

Please sign in to comment.