Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: PUT profile #33

Merged
merged 9 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
git checkout main
git pull origin main
docker-compose -f ~/chit-chat-backend/docker/DockerCompose/docker-compose.prod.yml down
docker system prune -a -f
docker system prune -a --volumes -f
docker-compose -f ~/chit-chat-backend/docker/DockerCompose/docker-compose.prod.yml build
docker-compose -f ~/chit-chat-backend/docker/DockerCompose/docker-compose.prod.yml up -d
EOF
2 changes: 2 additions & 0 deletions docker/DockerCompose/docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
- ASPNETCORE_ENVIRONMENT=Production
- ASPNETCORE_Kestrel__Certificates__Default__Path=/app/chitchat.pfx
- ASPNETCORE_Kestrel__Certificates__Default__Password=chitchat
env_file:
- ../../src/ChitChat.WebAPI/.env
networks:
- productnetwork
restart: unless-stopped
Expand Down
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
9 changes: 5 additions & 4 deletions src/ChitChat.WebAPI/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
# Stage 1: Base
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS base
WORKDIR /app
EXPOSE 8080
EXPOSE 8081

# Stage 2: Build
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src

# Update Copy SRC
# Copy project files and restore dependencies
COPY ["src/ChitChat.WebAPI/ChitChat.WebAPI.csproj", "ChitChat.WebAPI/"]
COPY ["src/ChitChat.Infrastructure/ChitChat.Infrastructure.csproj", "ChitChat.Infrastructure/"]
COPY ["src/ChitChat.Application/ChitChat.Application.csproj", "ChitChat.Application/"]
COPY ["src/ChitChat.DataAccess/ChitChat.DataAccess.csproj", "ChitChat.DataAccess/"]
COPY ["src/ChitChat.Domain/ChitChat.Domain.csproj", "ChitChat.Domain/"]
RUN dotnet restore "ChitChat.WebAPI/ChitChat.WebAPI.csproj"

# Copy the remaining source code and build
COPY src/ .
WORKDIR "/src/ChitChat.WebAPI"
RUN dotnet build "ChitChat.WebAPI.csproj" -c $BUILD_CONFIGURATION -o /app/build
Expand All @@ -30,7 +31,7 @@ FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .

# If env is Prod then cp SSL cert
# Copy SSL certificate if Production
ARG ENVIRONMENT=Development
COPY ["src/ChitChat.WebAPI/chitchat.pfx", "/app/chitchat.pfx"]
RUN if [ "$ENVIRONMENT" = "Production" ]; then cp /app/chitchat.pfx /app/chitchat.pfx; fi
Expand Down
Loading