diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 20f42f2..65e48ef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,18 +45,17 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - + ##ref: https://docs.docker.com/language/golang/configure-ci-cd/ + ##ref: https://event-driven.io/en/how_to_buid_and_push_docker_image_with_github_actions - name: Login to DockerHub uses: docker/login-action@v2 - if: ${{ github.ref == 'refs/heads/main' && success() }} + if: ${{ github.ref == 'refs/heads/main' && success() && github.event_name == 'pull_request' }} with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - ##ref: https://docs.docker.com/language/golang/configure-ci-cd/ - ##ref: https://event-driven.io/en/how_to_buid_and_push_docker_image_with_github_actions - name: Build Docker Image - if: ${{ github.ref == 'refs/heads/main' && success() }} + if: ${{ github.ref == 'refs/heads/main' && success() && github.event_name == 'pull_request' }} run: | docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-flight:${{ steps.last_release.outputs.tag_name }} -f "${{ github.workspace }}/src/Services/Flight/Dockerfile" . docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-identity:${{ steps.last_release.outputs.tag_name }} -f "${{ github.workspace }}/src/Services/Identity/Dockerfile" . @@ -64,7 +63,7 @@ jobs: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-booking:${{ steps.last_release.outputs.tag_name }} -f "${{ github.workspace }}/src/Services/Booking/Dockerfile" . - name: Publish Docker Image - if: ${{ github.ref == 'refs/heads/main' && success() }} + if: ${{ github.ref == 'refs/heads/main' && success() && github.event_name == 'pull_request' }} run: | docker push ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-flight:${{ steps.last_release.outputs.tag_name }} docker push ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-identity:${{ steps.last_release.outputs.tag_name }} diff --git a/src/BuildingBlocks/PersistMessageProcessor/Data/PersistMessageDbContext.cs b/src/BuildingBlocks/PersistMessageProcessor/Data/PersistMessageDbContext.cs index 70a4a6b..a38f9b0 100644 --- a/src/BuildingBlocks/PersistMessageProcessor/Data/PersistMessageDbContext.cs +++ b/src/BuildingBlocks/PersistMessageProcessor/Data/PersistMessageDbContext.cs @@ -8,6 +8,7 @@ using Configurations; using Core.Model; using global::Polly; using Microsoft.Extensions.Logging; +using Newtonsoft.Json; using Exception = System.Exception; public class PersistMessageDbContext : DbContext, IPersistMessageDbContext @@ -52,27 +53,23 @@ public class PersistMessageDbContext : DbContext, IPersistMessageDbContext { return await policy.ExecuteAsync(async () => await base.SaveChangesAsync(cancellationToken)); } + //ref: https://learn.microsoft.com/en-us/ef/core/saving/concurrency?tabs=data-annotations#resolving-concurrency-conflicts catch (DbUpdateConcurrencyException ex) { foreach (var entry in ex.Entries) { - var currentValue = entry.Entity; // we can use it for specific merging - var databaseValue = await entry.GetDatabaseValuesAsync(cancellationToken); + var currentValues = entry.CurrentValues; + var databaseValues = await entry.GetDatabaseValuesAsync(cancellationToken); _logger.LogInformation( - "Entry to entity with type: {Type}, database-value: {DatabaseValue} and current-value: {CurrentValue}", - entry.GetType().Name, - databaseValue, - currentValue); + "Entry to entity with database-value: {DatabaseValues} and current-value: {CurrentValues}", + JsonConvert.SerializeObject(databaseValues, + new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }), + JsonConvert.SerializeObject(currentValues, + new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); - if (databaseValue != null) - { - entry.OriginalValues.SetValues(databaseValue); - } - else - { - entry.OriginalValues.SetValues(currentValue); - } + // Refresh the original values with current values + entry.OriginalValues.SetValues(currentValues); } return await base.SaveChangesAsync(cancellationToken); diff --git a/src/Services/Booking/src/Booking.Api/Properties/launchSettings.json b/src/Services/Booking/src/Booking.Api/Properties/launchSettings.json index 0207d20..ef114c1 100644 --- a/src/Services/Booking/src/Booking.Api/Properties/launchSettings.json +++ b/src/Services/Booking/src/Booking.Api/Properties/launchSettings.json @@ -1,15 +1,17 @@ { "$schema": "https://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:53934", - "sslPort": 44392 - } - }, "profiles": { - "Booking.Api": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:6010", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, diff --git a/src/Services/Flight/src/Flight.Api/Properties/launchSettings.json b/src/Services/Flight/src/Flight.Api/Properties/launchSettings.json index 031b217..dd00f3d 100644 --- a/src/Services/Flight/src/Flight.Api/Properties/launchSettings.json +++ b/src/Services/Flight/src/Flight.Api/Properties/launchSettings.json @@ -1,15 +1,17 @@ { "$schema": "https://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:59936", - "sslPort": 44319 - } - }, "profiles": { - "Flight.Api": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5004", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, @@ -18,14 +20,8 @@ "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } - }, - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "launchUrl": "swagger", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } } } } + + diff --git a/src/Services/Identity/src/Identity.Api/Properties/launchSettings.json b/src/Services/Identity/src/Identity.Api/Properties/launchSettings.json index c321a06..5e419f6 100644 --- a/src/Services/Identity/src/Identity.Api/Properties/launchSettings.json +++ b/src/Services/Identity/src/Identity.Api/Properties/launchSettings.json @@ -1,28 +1,12 @@ { "$schema": "https://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:42478", - "sslPort": 44342 - } - }, "profiles": { - "Identity.Api": { + "https": { "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "swagger", - "applicationUrl": "https://localhost:5005;http://localhost:6005", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": false, - "launchUrl": "swagger", + "applicationUrl": "https://localhost:5005", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/src/Services/Passenger/src/Passenger.Api/Properties/launchSettings.json b/src/Services/Passenger/src/Passenger.Api/Properties/launchSettings.json index 5609b39..7b8730a 100644 --- a/src/Services/Passenger/src/Passenger.Api/Properties/launchSettings.json +++ b/src/Services/Passenger/src/Passenger.Api/Properties/launchSettings.json @@ -1,15 +1,17 @@ { "$schema": "https://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:32326", - "sslPort": 44374 - } - }, "profiles": { - "Passenger.Api": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:6012", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true,