Browse Source

Add a Coupon service initial code

pull/2020/head
facepalm 2 years ago
parent
commit
e80e1b0d0e
49 changed files with 10969 additions and 7845 deletions
  1. +1
    -0
      src/ApiGateways/Mobile.Bff.Shopping/aggregator/Dockerfile
  2. +2
    -1
      src/ApiGateways/Mobile.Bff.Shopping/aggregator/appsettings.localhost.json
  3. +1
    -0
      src/ApiGateways/Web.Bff.Shopping/aggregator/Dockerfile
  4. +2
    -1
      src/ApiGateways/Web.Bff.Shopping/aggregator/appsettings.localhost.json
  5. +1
    -0
      src/Services/Basket/Basket.API/Dockerfile
  6. +1
    -0
      src/Services/Catalog/Catalog.API/Dockerfile
  7. +1
    -0
      src/Services/Catalog/Catalog.API/Startup.cs
  8. +44
    -0
      src/Services/Coupon/Coupon.API/Controllers/CouponController.cs
  9. +40
    -0
      src/Services/Coupon/Coupon.API/Coupon.API.csproj
  10. +15
    -0
      src/Services/Coupon/Coupon.API/CouponSettings.cs
  11. +62
    -0
      src/Services/Coupon/Coupon.API/Dockerfile
  12. +9
    -0
      src/Services/Coupon/Coupon.API/Dtos/CouponDto.cs
  13. +7
    -0
      src/Services/Coupon/Coupon.API/Dtos/IMapper.cs
  14. +16
    -0
      src/Services/Coupon/Coupon.API/Dtos/Mapper.cs
  15. +49
    -0
      src/Services/Coupon/Coupon.API/Extensions/IHostBuilderExtensions.cs
  16. +249
    -0
      src/Services/Coupon/Coupon.API/Extensions/IServiceCollectionExtensions.cs
  17. +35
    -0
      src/Services/Coupon/Coupon.API/Filters/AuthorizeCheckOperationFilter.cs
  18. +16
    -0
      src/Services/Coupon/Coupon.API/Filters/ValidateModelAttribute.cs
  19. +52
    -0
      src/Services/Coupon/Coupon.API/Infrastructure/CouponSeed.cs
  20. +20
    -0
      src/Services/Coupon/Coupon.API/Infrastructure/Models/Coupon.cs
  21. +25
    -0
      src/Services/Coupon/Coupon.API/Infrastructure/Repositories/CouponContext.cs
  22. +42
    -0
      src/Services/Coupon/Coupon.API/Infrastructure/Repositories/CouponRepository.cs
  23. +14
    -0
      src/Services/Coupon/Coupon.API/Infrastructure/Repositories/ICouponRepository.cs
  24. +56
    -0
      src/Services/Coupon/Coupon.API/IntegrationEvents/EventHandlers/OrderStatusChangedToAwaitingCouponValidationIntegrationEventHandler.cs
  25. +22
    -0
      src/Services/Coupon/Coupon.API/IntegrationEvents/EventHandlers/OrderStatusChangedToCancelledIntegrationEventHandler.cs
  26. +17
    -0
      src/Services/Coupon/Coupon.API/IntegrationEvents/Events/OrderCouponConfirmedIntegrationEvent.cs
  27. +17
    -0
      src/Services/Coupon/Coupon.API/IntegrationEvents/Events/OrderCouponRejectedIntegrationEvent.cs
  28. +20
    -0
      src/Services/Coupon/Coupon.API/IntegrationEvents/Events/OrderStatusChangedToAwaitingCouponValidationIntegrationEvent.cs
  29. +24
    -0
      src/Services/Coupon/Coupon.API/IntegrationEvents/Events/OrderStatusChangedToCancelledIntegrationEvent.cs
  30. +53
    -0
      src/Services/Coupon/Coupon.API/Program.cs
  31. +12
    -0
      src/Services/Coupon/Coupon.API/Properties/launchSettings.json
  32. +94
    -0
      src/Services/Coupon/Coupon.API/Startup.cs
  33. +18
    -0
      src/Services/Coupon/Coupon.API/appsettings.Development.json
  34. +28
    -0
      src/Services/Coupon/Coupon.API/appsettings.json
  35. +1
    -0
      src/Services/Identity/Identity.API/Dockerfile
  36. +1
    -0
      src/Services/Ordering/Ordering.API/Dockerfile
  37. +1
    -0
      src/Services/Ordering/Ordering.BackgroundTasks/Dockerfile
  38. +1
    -0
      src/Services/Ordering/Ordering.SignalrHub/Dockerfile
  39. +1
    -0
      src/Services/Payment/Payment.API/Dockerfile
  40. +1
    -0
      src/Services/Webhooks/Webhooks.API/Dockerfile
  41. +1
    -0
      src/Web/WebMVC/Dockerfile
  42. +9787
    -7838
      src/Web/WebSPA/Client/yarn.lock
  43. +7
    -0
      src/Web/WebSPA/Dockerfile
  44. +1
    -0
      src/Web/WebStatus/Dockerfile
  45. +1
    -0
      src/Web/WebhookClient/Dockerfile
  46. +20
    -1
      src/docker-compose.override.yml
  47. +14
    -0
      src/docker-compose.prod.yml
  48. +9
    -0
      src/docker-compose.yml
  49. +58
    -4
      src/eShopOnContainers-ServicesAndWebApps.sln

+ 1
- 0
src/ApiGateways/Mobile.Bff.Shopping/aggregator/Dockerfile View File

@ -34,6 +34,7 @@ COPY "Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj" "Service
COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj"
COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj" COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj"
COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj"
COPY "Services/Coupon/Coupon.API/Coupon.API.csproj" "Services/Coupon/Coupon.API/Coupon.API.csproj"
COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj"
COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj" COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj"
COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj" COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj"


+ 2
- 1
src/ApiGateways/Mobile.Bff.Shopping/aggregator/appsettings.localhost.json View File

@ -6,7 +6,8 @@
"identity": "http://localhost:55105", "identity": "http://localhost:55105",
"grpcBasket": "http://localhost:5580", "grpcBasket": "http://localhost:5580",
"grpcCatalog": "http://localhost:81", "grpcCatalog": "http://localhost:81",
"grpcOrdering": "http://localhost:5581"
"grpcOrdering": "http://localhost:5581",
"coupon": "http://localhost:55106"
}, },
"IdentityUrlExternal": "http://localhost:5105", "IdentityUrlExternal": "http://localhost:5105",
"IdentityUrl": "http://localhost:5105", "IdentityUrl": "http://localhost:5105",


+ 1
- 0
src/ApiGateways/Web.Bff.Shopping/aggregator/Dockerfile View File

@ -34,6 +34,7 @@ COPY "Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj" "Service
COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj"
COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj" COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj"
COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj"
COPY "Services/Coupon/Coupon.API/Coupon.API.csproj" "Services/Coupon/Coupon.API/Coupon.API.csproj"
COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj"
COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj" COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj"
COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj" COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj"


+ 2
- 1
src/ApiGateways/Web.Bff.Shopping/aggregator/appsettings.localhost.json View File

@ -6,6 +6,7 @@
"identity": "http://localhost:55105", "identity": "http://localhost:55105",
"grpcBasket": "http://localhost:5580", "grpcBasket": "http://localhost:5580",
"grpcCatalog": "http://localhost:81", "grpcCatalog": "http://localhost:81",
"grpcOrdering": "http://localhost:5581"
"grpcOrdering": "http://localhost:5581",
"coupon": "http://localhost:55106"
} }
} }

+ 1
- 0
src/Services/Basket/Basket.API/Dockerfile View File

@ -34,6 +34,7 @@ COPY "Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj" "Service
COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj"
COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj" COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj"
COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj"
COPY "Services/Coupon/Coupon.API/Coupon.API.csproj" "Services/Coupon/Coupon.API/Coupon.API.csproj"
COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj"
COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj" COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj"
COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj" COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj"


+ 1
- 0
src/Services/Catalog/Catalog.API/Dockerfile View File

@ -35,6 +35,7 @@ COPY "Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj" "Service
COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj"
COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj" COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj"
COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj"
COPY "Services/Coupon/Coupon.API/Coupon.API.csproj" "Services/Coupon/Coupon.API/Coupon.API.csproj"
COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj"
COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj" COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj"
COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj" COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj"


+ 1
- 0
src/Services/Catalog/Catalog.API/Startup.cs View File

@ -171,6 +171,7 @@ public static class CustomExtensionMethods
services.AddEntityFrameworkSqlServer() services.AddEntityFrameworkSqlServer()
.AddDbContext<CatalogContext>(options => .AddDbContext<CatalogContext>(options =>
{ {
var st = configuration["ConnectionString"];
options.UseSqlServer(configuration["ConnectionString"], options.UseSqlServer(configuration["ConnectionString"],
sqlServerOptionsAction: sqlOptions => sqlServerOptionsAction: sqlOptions =>
{ {


+ 44
- 0
src/Services/Coupon/Coupon.API/Controllers/CouponController.cs View File

@ -0,0 +1,44 @@
namespace Coupon.API.Controllers
{
using System.Net;
using System.Threading.Tasks;
using Coupon.API.Dtos;
using Coupon.API.Infrastructure.Models;
using Coupon.API.Infrastructure.Repositories;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
[Authorize]
[ApiController]
[Route("api/v1/[controller]")]
public class CouponController : ControllerBase
{
private readonly ICouponRepository _couponRepository;
private readonly IMapper<CouponDto, Coupon> _mapper;
public CouponController(ICouponRepository couponRepository, IMapper<CouponDto, Coupon> mapper)
{
_couponRepository = couponRepository;
_mapper = mapper;
}
[HttpGet("{code}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult<CouponDto>> GetCouponByCodeAsync(string code)
{
var coupon = await _couponRepository.FindCouponByCodeAsync(code);
if (coupon is null || coupon.Consumed)
{
return NotFound();
}
var couponDto = _mapper.Translate(coupon);
return couponDto;
}
}
}

+ 40
- 0
src/Services/Coupon/Coupon.API/Coupon.API.csproj View File

@ -0,0 +1,40 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<UserSecretsId>1d5bc948-90f1-4906-a1f8-8edaa1ed9e2e</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..\..\..</DockerfileContext>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.AzureServiceBus" Version="6.0.3" />
<PackageReference Include="AspNetCore.HealthChecks.MongoDb" Version="6.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="6.0.2" />
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="6.0.2" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="6.0.4" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.20.0" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.3" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="3.1.23" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.15.0" />
<PackageReference Include="MongoDB.Driver.Core" Version="2.13.3" />
<PackageReference Include="Polly" Version="7.2.3" />
<PackageReference Include="Serilog.AspNetCore" Version="5.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.3.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
<PackageReference Include="Serilog.Sinks.Http" Version="7.2.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="5.1.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.16.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBusRabbitMQ\EventBusRabbitMQ.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBusServiceBus\EventBusServiceBus.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBus\EventBus.csproj" />
</ItemGroup>
</Project>

+ 15
- 0
src/Services/Coupon/Coupon.API/CouponSettings.cs View File

@ -0,0 +1,15 @@
namespace Coupon.API
{
public class CouponSettings
{
public string ConnectionString { get; set; }
public string CouponMongoDatabase { get; set; }
public string EventBusConnection { get; set; }
public bool UseCustomizationData { get; set; }
public bool AzureStorageEnabled { get; set; }
}
}

+ 62
- 0
src/Services/Coupon/Coupon.API/Dockerfile View File

@ -0,0 +1,62 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
# It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles
# to take advantage of Docker's build cache, to speed up local container builds
COPY "eShopOnContainers-ServicesAndWebApps.sln" "eShopOnContainers-ServicesAndWebApps.sln"
COPY "ApiGateways/Mobile.Bff.Shopping/aggregator/Mobile.Shopping.HttpAggregator.csproj" "ApiGateways/Mobile.Bff.Shopping/aggregator/Mobile.Shopping.HttpAggregator.csproj"
COPY "ApiGateways/Web.Bff.Shopping/aggregator/Web.Shopping.HttpAggregator.csproj" "ApiGateways/Web.Bff.Shopping/aggregator/Web.Shopping.HttpAggregator.csproj"
COPY "BuildingBlocks/Devspaces.Support/Devspaces.Support.csproj" "BuildingBlocks/Devspaces.Support/Devspaces.Support.csproj"
COPY "BuildingBlocks/EventBus/EventBus/EventBus.csproj" "BuildingBlocks/EventBus/EventBus/EventBus.csproj"
COPY "BuildingBlocks/EventBus/EventBus.Tests/EventBus.Tests.csproj" "BuildingBlocks/EventBus/EventBus.Tests/EventBus.Tests.csproj"
COPY "BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj" "BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj"
COPY "BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj" "BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj"
COPY "BuildingBlocks/EventBus/IntegrationEventLogEF/IntegrationEventLogEF.csproj" "BuildingBlocks/EventBus/IntegrationEventLogEF/IntegrationEventLogEF.csproj"
COPY "BuildingBlocks/WebHostCustomization/WebHost.Customization/WebHost.Customization.csproj" "BuildingBlocks/WebHostCustomization/WebHost.Customization/WebHost.Customization.csproj"
COPY "Services/Basket/Basket.API/Basket.API.csproj" "Services/Basket/Basket.API/Basket.API.csproj"
COPY "Services/Basket/Basket.FunctionalTests/Basket.FunctionalTests.csproj" "Services/Basket/Basket.FunctionalTests/Basket.FunctionalTests.csproj"
COPY "Services/Basket/Basket.UnitTests/Basket.UnitTests.csproj" "Services/Basket/Basket.UnitTests/Basket.UnitTests.csproj"
COPY "Services/Catalog/Catalog.API/Catalog.API.csproj" "Services/Catalog/Catalog.API/Catalog.API.csproj"
COPY "Services/Catalog/Catalog.FunctionalTests/Catalog.FunctionalTests.csproj" "Services/Catalog/Catalog.FunctionalTests/Catalog.FunctionalTests.csproj"
COPY "Services/Catalog/Catalog.UnitTests/Catalog.UnitTests.csproj" "Services/Catalog/Catalog.UnitTests/Catalog.UnitTests.csproj"
COPY "Services/Identity/Identity.API/Identity.API.csproj" "Services/Identity/Identity.API/Identity.API.csproj"
COPY "Services/Ordering/Ordering.API/Ordering.API.csproj" "Services/Ordering/Ordering.API/Ordering.API.csproj"
COPY "Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj" "Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj"
COPY "Services/Ordering/Ordering.Domain/Ordering.Domain.csproj" "Services/Ordering/Ordering.Domain/Ordering.Domain.csproj"
COPY "Services/Ordering/Ordering.FunctionalTests/Ordering.FunctionalTests.csproj" "Services/Ordering/Ordering.FunctionalTests/Ordering.FunctionalTests.csproj"
COPY "Services/Ordering/Ordering.Infrastructure/Ordering.Infrastructure.csproj" "Services/Ordering/Ordering.Infrastructure/Ordering.Infrastructure.csproj"
COPY "Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj" "Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj"
COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj"
COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj"
COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj"
COPY "Services/Coupon/Coupon.API/Coupon.API.csproj" "Services/Coupon/Coupon.API/Coupon.API.csproj"
COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj"
COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj"
COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj"
COPY "Web/WebSPA/WebSPA.csproj" "Web/WebSPA/WebSPA.csproj"
COPY "Web/WebStatus/WebStatus.csproj" "Web/WebStatus/WebStatus.csproj"
COPY "docker-compose.dcproj" "docker-compose.dcproj"
COPY "NuGet.config" "NuGet.config"
RUN dotnet restore "eShopOnContainers-ServicesAndWebApps.sln"
COPY . .
WORKDIR /src/Services/Coupon/Coupon.API
RUN dotnet publish --no-restore -c Release -o /app
FROM build AS publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "Coupon.API.dll"]

+ 9
- 0
src/Services/Coupon/Coupon.API/Dtos/CouponDto.cs View File

@ -0,0 +1,9 @@
namespace Coupon.API.Dtos
{
public class CouponDto
{
public int Discount { get; set; }
public string Code { get; set; }
}
}

+ 7
- 0
src/Services/Coupon/Coupon.API/Dtos/IMapper.cs View File

@ -0,0 +1,7 @@
namespace Coupon.API.Dtos
{
public interface IMapper<TResult, TEntity>
{
TResult Translate(TEntity entity);
}
}

+ 16
- 0
src/Services/Coupon/Coupon.API/Dtos/Mapper.cs View File

@ -0,0 +1,16 @@
namespace Coupon.API.Dtos
{
using Coupon.API.Infrastructure.Models;
public class Mapper : IMapper<CouponDto, Coupon>
{
public CouponDto Translate(Coupon entity)
{
return new CouponDto
{
Code = entity.Code,
Discount = entity.Discount
};
}
}
}

+ 49
- 0
src/Services/Coupon/Coupon.API/Extensions/IHostBuilderExtensions.cs View File

@ -0,0 +1,49 @@
using System;
using Microsoft.Data.SqlClient;
using Coupon.API.IntegrationEvents.EventHandlers;
using Coupon.API.IntegrationEvents.Events;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Polly;
namespace Coupon.API.Extensions
{
public static class IHostBuilderExtensions
{
public static IHost SeedDatabaseStrategy<TContext>(this IHost host, Action<TContext> seeder)
{
using (var scope = host.Services.CreateScope())
{
var context = scope.ServiceProvider.GetService<TContext>();
var policy = Policy.Handle<SqlException>()
.WaitAndRetry(new TimeSpan[]
{
TimeSpan.FromSeconds(3),
TimeSpan.FromSeconds(5),
TimeSpan.FromSeconds(8),
});
policy.Execute(() =>
{
seeder.Invoke(context);
});
}
return host;
}
public static IHost SubscribersIntegrationEvents(this IHost host)
{
using (var scope = host.Services.CreateScope())
{
var eventBus = scope.ServiceProvider.GetRequiredService<IEventBus>();
eventBus.Subscribe<OrderStatusChangedToAwaitingCouponValidationIntegrationEvent, OrderStatusChangedToAwaitingCouponValidationIntegrationEventHandler>();
}
return host;
}
}
}

+ 249
- 0
src/Services/Coupon/Coupon.API/Extensions/IServiceCollectionExtensions.cs View File

@ -0,0 +1,249 @@
namespace Coupon.API.Extensions
{
using System;
using System.Collections.Generic;
using Autofac;
using Coupon.API.Dtos;
using Coupon.API.Filters;
using Coupon.API.Infrastructure.Models;
using Coupon.API.Infrastructure.Repositories;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Models;
using RabbitMQ.Client;
public static class IServiceCollectionExtensions
{
public static IServiceCollection AddCouponRegister(this IServiceCollection services, IConfiguration configuration)
{
if (configuration.GetValue<bool>("AzureServiceBusEnabled"))
{
services.AddSingleton<IServiceBusPersisterConnection>(sp =>
{
var serviceBusConnectionString = configuration["EventBusConnection"];
return new DefaultServiceBusPersisterConnection(serviceBusConnectionString);
});
}
else
{
services.AddSingleton<IRabbitMQPersistentConnection>(sp =>
{
var logger = sp.GetRequiredService<ILogger<DefaultRabbitMQPersistentConnection>>();
var factory = new ConnectionFactory()
{
HostName = configuration["EventBusConnection"],
DispatchConsumersAsync = true
};
if (!string.IsNullOrEmpty(configuration["EventBusUserName"]))
{
factory.UserName = configuration["EventBusUserName"];
}
if (!string.IsNullOrEmpty(configuration["EventBusPassword"]))
{
factory.Password = configuration["EventBusPassword"];
}
var retryCount = 5;
if (!string.IsNullOrEmpty(configuration["EventBusRetryCount"]))
{
retryCount = int.Parse(configuration["EventBusRetryCount"]);
}
return new DefaultRabbitMQPersistentConnection(factory, logger, retryCount);
});
}
services.AddTransient<ICouponRepository, CouponRepository>()
.AddTransient<IEventBusSubscriptionsManager, InMemoryEventBusSubscriptionsManager>()
.AddTransient<CouponContext>()
.AddTransient<IMapper<CouponDto, Coupon>, Mapper>();
return services;
}
public static IServiceCollection AddSwagger(this IServiceCollection services, IConfiguration configuration)
{
services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new OpenApiInfo
{
Title = "eShopOnContainers - Coupon HTTP API",
Version = "v1",
Description = "The Coupon Service HTTP API"
});
options.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme
{
Type = SecuritySchemeType.OAuth2,
Flows = new OpenApiOAuthFlows()
{
Implicit = new OpenApiOAuthFlow()
{
AuthorizationUrl = new Uri($"{configuration.GetValue<string>("IdentityUrlExternal")}/connect/authorize"),
TokenUrl = new Uri($"{configuration.GetValue<string>("IdentityUrlExternal")}/connect/token"),
Scopes = new Dictionary<string, string>()
{
{ "coupon", "Coupon API" }
}
}
}
});
options.OperationFilter<AuthorizeCheckOperationFilter>();
});
return services;
}
public static IServiceCollection AddCustomSettings(this IServiceCollection services, IConfiguration configuration)
{
services.Configure<CouponSettings>(configuration);
services.Configure<ApiBehaviorOptions>(options =>
{
options.InvalidModelStateResponseFactory = context =>
{
var problemDetails = new ValidationProblemDetails(context.ModelState)
{
Instance = context.HttpContext.Request.Path,
Status = StatusCodes.Status400BadRequest,
Detail = "Please refer to the errors property for additional details."
};
return new BadRequestObjectResult(problemDetails)
{
ContentTypes = { "application/problem+json", "application/problem+xml" }
};
};
});
return services;
}
public static IServiceCollection AddEventBus(this IServiceCollection services, IConfiguration configuration)
{
var subscriptionClientName = configuration["SubscriptionClientName"];
if (configuration.GetValue<bool>("AzureServiceBusEnabled"))
{
services.AddSingleton<IEventBus, EventBusServiceBus>(sp =>
{
var serviceBusPersisterConnection = sp.GetRequiredService<IServiceBusPersisterConnection>();
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
return new EventBusServiceBus(
serviceBusPersisterConnection,
logger,
eventBusSubcriptionsManager,
iLifetimeScope,
subscriptionClientName);
});
}
else
{
services.AddSingleton<IEventBus, EventBusRabbitMQ>(sp =>
{
var rabbitMQPersistentConnection = sp.GetRequiredService<IRabbitMQPersistentConnection>();
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
var logger = sp.GetRequiredService<ILogger<EventBusRabbitMQ>>();
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
var retryCount = 5;
if (!string.IsNullOrEmpty(configuration["EventBusRetryCount"]))
{
retryCount = int.Parse(configuration["EventBusRetryCount"]);
}
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
});
}
return services;
}
public static IServiceCollection AddCustomHealthCheck(this IServiceCollection services, IConfiguration configuration)
{
var accountName = configuration.GetValue<string>("AzureStorageAccountName");
var accountKey = configuration.GetValue<string>("AzureStorageAccountKey");
var hcBuilder = services.AddHealthChecks();
hcBuilder.AddCheck("self", () => HealthCheckResult.Healthy())
.AddMongoDb(
configuration["ConnectionString"],
name: "CouponCollection-check",
tags: new string[] { "couponcollection" });
if (configuration.GetValue<bool>("AzureServiceBusEnabled"))
{
hcBuilder.AddAzureServiceBusTopic(
configuration["EventBusConnection"],
topicName: "eshop_event_bus",
name: "coupon-servicebus-check",
tags: new string[] { "servicebus" });
}
else
{
hcBuilder.AddRabbitMQ(
$"amqp://{configuration["EventBusConnection"]}",
name: "coupon-rabbitmqbus-check",
tags: new string[] { "rabbitmqbus" });
}
return services;
}
public static IServiceCollection AddCustomPolicies(this IServiceCollection services)
{
services.AddCors(options =>
{
options.AddPolicy("CorsPolicy",
builder => builder.SetIsOriginAllowed((host) => true)
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials());
});
return services;
}
public static IServiceCollection AddAppInsights(this IServiceCollection services, IConfiguration configuration)
{
services.AddApplicationInsightsTelemetry(configuration);
services.AddApplicationInsightsKubernetesEnricher();
return services;
}
public static IServiceCollection AddCustomAuthentication(this IServiceCollection services, IConfiguration configuration)
{
return services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
}).AddJwtBearer(options =>
{
options.Authority = configuration["IdentityUrl"];
options.RequireHttpsMetadata = false;
options.Audience = "coupon";
}).Services;
}
public static IServiceCollection AddCustomAuthorization(this IServiceCollection services) => services.AddAuthorization();
}
}

+ 35
- 0
src/Services/Coupon/Coupon.API/Filters/AuthorizeCheckOperationFilter.cs View File

@ -0,0 +1,35 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Authorization;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
namespace Coupon.API.Filters
{
public class AuthorizeCheckOperationFilter : IOperationFilter
{
public void Apply(OpenApiOperation operation, OperationFilterContext context)
{
var hasAuthorize = context.MethodInfo.DeclaringType.GetCustomAttributes(true).OfType<AuthorizeAttribute>().Any() ||
context.MethodInfo.GetCustomAttributes(true).OfType<AuthorizeAttribute>().Any();
if (!hasAuthorize) return;
operation.Responses.TryAdd("401", new OpenApiResponse { Description = "Unauthorized" });
operation.Responses.TryAdd("403", new OpenApiResponse { Description = "Forbidden" });
var oAuthScheme = new OpenApiSecurityScheme
{
Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "oauth2" }
};
operation.Security = new List<OpenApiSecurityRequirement>
{
new OpenApiSecurityRequirement
{
[oAuthScheme] = new [] { "CouponApi" }
}
};
}
}
}

+ 16
- 0
src/Services/Coupon/Coupon.API/Filters/ValidateModelAttribute.cs View File

@ -0,0 +1,16 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
namespace Coupon.API.Filters
{
public class ValidateModelAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext context)
{
if (!context.ModelState.IsValid)
{
context.Result = new BadRequestObjectResult(context.ModelState);
}
}
}
}

+ 52
- 0
src/Services/Coupon/Coupon.API/Infrastructure/CouponSeed.cs View File

@ -0,0 +1,52 @@
namespace Coupon.API.Infrastructure
{
using System.Collections.Generic;
using System.Threading.Tasks;
using Coupon.API.Infrastructure.Models;
using Coupon.API.Infrastructure.Repositories;
public class CouponSeed
{
public async Task SeedAsync(CouponContext context)
{
if (context.Coupons.EstimatedDocumentCount() == 0)
{
var coupons = new List<Coupon>
{
new Coupon
{
Code = "DISC-5",
Discount = 5
},
new Coupon
{
Code = "DISC-10",
Discount = 10
},
new Coupon
{
Code = "DISC-15",
Discount = 15
},
new Coupon
{
Code = "DISC-20",
Discount = 20
},
new Coupon
{
Code = "DISC-25",
Discount = 25
},
new Coupon
{
Code = "DISC-30",
Discount = 30
}
};
await context.Coupons.InsertManyAsync(coupons);
}
}
}
}

+ 20
- 0
src/Services/Coupon/Coupon.API/Infrastructure/Models/Coupon.cs View File

@ -0,0 +1,20 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
namespace Coupon.API.Infrastructure.Models
{
public class Coupon
{
[BsonIgnoreIfDefault]
[BsonRepresentation(BsonType.ObjectId)]
public string Id { get; set; }
public int Discount { get; set; }
public string Code { get; set; }
public bool Consumed { get; set; }
public int OrderId { get; set; }
}
}

+ 25
- 0
src/Services/Coupon/Coupon.API/Infrastructure/Repositories/CouponContext.cs View File

@ -0,0 +1,25 @@
namespace Coupon.API.Infrastructure.Repositories
{
using Coupon.API.Infrastructure.Models;
using Microsoft.Extensions.Options;
using MongoDB.Driver;
public class CouponContext
{
private readonly IMongoDatabase _database = null;
public CouponContext(IOptions<CouponSettings> settings)
{
var client = new MongoClient(settings.Value.ConnectionString);
if (client is null)
{
throw new MongoConfigurationException("Cannot connect to the database. The connection string is not valid or the database is not accessible");
}
_database = client.GetDatabase(settings.Value.CouponMongoDatabase);
}
public IMongoCollection<Coupon> Coupons => _database.GetCollection<Coupon>("CouponCollection");
}
}

+ 42
- 0
src/Services/Coupon/Coupon.API/Infrastructure/Repositories/CouponRepository.cs View File

@ -0,0 +1,42 @@
namespace Coupon.API.Infrastructure.Repositories
{
using System.Threading.Tasks;
using Coupon.API.Infrastructure.Models;
using MongoDB.Driver;
public class CouponRepository : ICouponRepository
{
private readonly CouponContext _couponContext;
public CouponRepository(CouponContext couponContext)
{
_couponContext = couponContext;
}
public async Task UpdateCouponConsumedByCodeAsync(string code, int orderId)
{
var filter = Builders<Coupon>.Filter.Eq("Code", code);
var update = Builders<Coupon>.Update
.Set(coupon => coupon.Consumed, true)
.Set(coupon => coupon.OrderId, orderId);
await _couponContext.Coupons.UpdateOneAsync(filter, update, new UpdateOptions { IsUpsert = false });
}
public async Task UpdateCouponReleasedByOrderIdAsync(int orderId)
{
var filter = Builders<Coupon>.Filter.Eq("OrderId", orderId);
var update = Builders<Coupon>.Update
.Set(coupon => coupon.Consumed, false)
.Set(coupon => coupon.OrderId, 0);
await _couponContext.Coupons.UpdateOneAsync(filter, update, new UpdateOptions { IsUpsert = false });
}
public async Task<Coupon> FindCouponByCodeAsync(string code)
{
var filter = Builders<Coupon>.Filter.Eq("Code", code);
return await _couponContext.Coupons.Find(filter).FirstOrDefaultAsync();
}
}
}

+ 14
- 0
src/Services/Coupon/Coupon.API/Infrastructure/Repositories/ICouponRepository.cs View File

@ -0,0 +1,14 @@
namespace Coupon.API.Infrastructure.Repositories
{
using System.Threading.Tasks;
using Coupon.API.Infrastructure.Models;
public interface ICouponRepository
{
Task<Coupon> FindCouponByCodeAsync(string code);
Task UpdateCouponConsumedByCodeAsync(string code, int orderId);
Task UpdateCouponReleasedByOrderIdAsync(int orderId);
}
}

+ 56
- 0
src/Services/Coupon/Coupon.API/IntegrationEvents/EventHandlers/OrderStatusChangedToAwaitingCouponValidationIntegrationEventHandler.cs View File

@ -0,0 +1,56 @@
using System.Threading.Tasks;
using Coupon.API.Infrastructure.Repositories;
using Coupon.API.IntegrationEvents.Events;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
using Serilog;
using Serilog.Context;
namespace Coupon.API.IntegrationEvents.EventHandlers
{
public class OrderStatusChangedToAwaitingCouponValidationIntegrationEventHandler : IIntegrationEventHandler<OrderStatusChangedToAwaitingCouponValidationIntegrationEvent>
{
private readonly ICouponRepository _couponRepository;
private readonly IEventBus _eventBus;
public OrderStatusChangedToAwaitingCouponValidationIntegrationEventHandler(ICouponRepository couponRepository, IEventBus eventBus)
{
_couponRepository = couponRepository;
_eventBus = eventBus;
}
public async Task Handle(OrderStatusChangedToAwaitingCouponValidationIntegrationEvent @event)
{
await Task.Delay(3000);
using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-Coupon.API"))
{
Log.Information("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, "Coupon.API", @event);
var couponIntegrationEvent = await ProcessIntegrationEventAsync(@event);
Log.Information("----- Publishing integration event: {IntegrationEventId} from {AppName} - ({@IntegrationEvent})", couponIntegrationEvent.Id, "Coupon.API", couponIntegrationEvent);
_eventBus.Publish(couponIntegrationEvent);
}
}
private async Task<IntegrationEvent> ProcessIntegrationEventAsync(OrderStatusChangedToAwaitingCouponValidationIntegrationEvent integrationEvent)
{
var coupon = await _couponRepository.FindCouponByCodeAsync(integrationEvent.Code);
Log.Information("----- Coupon \"{CouponCode}\": {@Coupon}", integrationEvent.Code, coupon);
if (coupon == null || coupon.Consumed)
{
return new OrderCouponRejectedIntegrationEvent(integrationEvent.OrderId, coupon.Code);
}
Log.Information("Consumed coupon: {DiscountCode}", integrationEvent.Code);
await _couponRepository.UpdateCouponConsumedByCodeAsync(integrationEvent.Code, integrationEvent.OrderId);
return new OrderCouponConfirmedIntegrationEvent(integrationEvent.OrderId, coupon.Discount);
}
}
}

+ 22
- 0
src/Services/Coupon/Coupon.API/IntegrationEvents/EventHandlers/OrderStatusChangedToCancelledIntegrationEventHandler.cs View File

@ -0,0 +1,22 @@
using System.Threading.Tasks;
using Coupon.API.Infrastructure.Repositories;
using Coupon.API.IntegrationEvents.Events;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
namespace Coupon.API.IntegrationEvents.EventHandlers
{
public class OrderStatusChangedToCancelledIntegrationEventHandler : IIntegrationEventHandler<OrderStatusChangedToCancelledIntegrationEvent>
{
private readonly ICouponRepository _couponRepository;
public OrderStatusChangedToCancelledIntegrationEventHandler(ICouponRepository couponRepository)
{
_couponRepository = couponRepository;
}
public async Task Handle(OrderStatusChangedToCancelledIntegrationEvent @event)
{
await _couponRepository.UpdateCouponReleasedByOrderIdAsync(@event.OrderId);
}
}
}

+ 17
- 0
src/Services/Coupon/Coupon.API/IntegrationEvents/Events/OrderCouponConfirmedIntegrationEvent.cs View File

@ -0,0 +1,17 @@
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
namespace Coupon.API.IntegrationEvents.Events
{
public record OrderCouponConfirmedIntegrationEvent : IntegrationEvent
{
public int OrderId { get; }
public int Discount { get; }
public OrderCouponConfirmedIntegrationEvent(int orderId, int discount)
{
OrderId = orderId;
Discount = discount;
}
}
}

+ 17
- 0
src/Services/Coupon/Coupon.API/IntegrationEvents/Events/OrderCouponRejectedIntegrationEvent.cs View File

@ -0,0 +1,17 @@
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
namespace Coupon.API.IntegrationEvents.Events
{
public record OrderCouponRejectedIntegrationEvent : IntegrationEvent
{
public int OrderId { get; }
public string Code { get; }
public OrderCouponRejectedIntegrationEvent(int orderId, string code)
{
OrderId = orderId;
Code = code;
}
}
}

+ 20
- 0
src/Services/Coupon/Coupon.API/IntegrationEvents/Events/OrderStatusChangedToAwaitingCouponValidationIntegrationEvent.cs View File

@ -0,0 +1,20 @@
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
using Newtonsoft.Json;
namespace Coupon.API.IntegrationEvents.Events
{
public record OrderStatusChangedToAwaitingCouponValidationIntegrationEvent : IntegrationEvent
{
[JsonProperty]
public int OrderId { get; private set; }
[JsonProperty]
public string OrderStatus { get; private set; }
[JsonProperty]
public string BuyerName { get; private set; }
[JsonProperty]
public string Code { get; private set; }
}
}

+ 24
- 0
src/Services/Coupon/Coupon.API/IntegrationEvents/Events/OrderStatusChangedToCancelledIntegrationEvent.cs View File

@ -0,0 +1,24 @@
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Coupon.API.IntegrationEvents.Events
{
public record OrderStatusChangedToCancelledIntegrationEvent : IntegrationEvent
{
[JsonProperty]
public int OrderId { get; private set; }
[JsonProperty]
public string OrderStatus { get; private set; }
[JsonProperty]
public string BuyerName { get; private set; }
[JsonProperty]
public string DiscountCode { get; private set; }
}
}

+ 53
- 0
src/Services/Coupon/Coupon.API/Program.cs View File

@ -0,0 +1,53 @@
using System.IO;
using Autofac.Extensions.DependencyInjection;
using Coupon.API.Extensions;
using Coupon.API.Infrastructure;
using Coupon.API.Infrastructure.Repositories;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Serilog;
using Serilog.Events;
namespace Coupon.API
{
public class Program
{
public static void Main(string[] args) =>
CreateHostBuilder(args)
.Build()
.SeedDatabaseStrategy<CouponContext>(context => new CouponSeed().SeedAsync(context).Wait())
.SubscribersIntegrationEvents()
.Run();
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureAppConfiguration((host, builder) =>
{
builder.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{host.HostingEnvironment.EnvironmentName}.json", optional: false, reloadOnChange: true)
.AddEnvironmentVariables();
var config = builder.Build();
if (config.GetValue("UseVault", false))
{
builder.AddAzureKeyVault($"https://{config["Vault:Name"]}.vault.azure.net/", config["Vault:ClientId"], config["Vault:ClientSecret"]);
}
})
.ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<Startup>())
.UseSerilog((host, builder) =>
{
builder.MinimumLevel.Verbose()
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.Enrich.WithProperty("ApplicationContext", host.HostingEnvironment.ApplicationName)
.Enrich.FromLogContext()
.WriteTo.Console()
.WriteTo.Seq(string.IsNullOrWhiteSpace(host.Configuration["Serilog:SeqServerUrl"]) ? "http://seq" : host.Configuration["Serilog:SeqServerUrl"])
.WriteTo.Http(string.IsNullOrWhiteSpace(host.Configuration["Serilog:LogstashUrl"]) ? "http://logstash:8080" : host.Configuration["Serilog:LogstashUrl"])
.ReadFrom.Configuration(host.Configuration);
});
}
}

+ 12
- 0
src/Services/Coupon/Coupon.API/Properties/launchSettings.json View File

@ -0,0 +1,12 @@
{
"profiles": {
"Microsoft.eShopOnContainers.Services.Coupon.API": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "http://localhost:55106/",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

+ 94
- 0
src/Services/Coupon/Coupon.API/Startup.cs View File

@ -0,0 +1,94 @@
using Coupon.API.Extensions;
using Coupon.API.Filters;
using Coupon.API.IntegrationEvents.EventHandlers;
using Coupon.API.IntegrationEvents.Events;
using HealthChecks.UI.Client;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Serilog;
namespace Coupon.API
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers(options => options.Filters.Add<ValidateModelAttribute>());
services.AddCustomSettings(Configuration)
.AddCouponRegister(Configuration)
.AddCustomPolicies()
.AddAppInsights(Configuration)
.AddEventBus(Configuration)
.AddCustomAuthentication(Configuration)
.AddCustomAuthorization()
.AddSwagger(Configuration)
.AddCustomHealthCheck(Configuration);
services.AddTransient<IIntegrationEventHandler<OrderStatusChangedToAwaitingCouponValidationIntegrationEvent>, OrderStatusChangedToAwaitingCouponValidationIntegrationEventHandler>();
services.AddTransient<IIntegrationEventHandler<OrderStatusChangedToCancelledIntegrationEvent>, OrderStatusChangedToCancelledIntegrationEventHandler>();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
var pathBase = Configuration["PATH_BASE"];
if (!string.IsNullOrEmpty(pathBase))
{
app.UsePathBase(pathBase);
}
app.UseSwagger()
.UseSwaggerUI(options =>
{
options.SwaggerEndpoint($"{ (!string.IsNullOrEmpty(pathBase) ? pathBase : string.Empty) }/swagger/v1/swagger.json", "Coupon.API V1");
options.OAuthClientId("couponswaggerui");
options.OAuthAppName("eShop-Learn.Coupon.API Swagger UI");
})
.UseCors("CorsPolicy")
.UseRouting()
.UseAuthentication()
.UseAuthorization()
.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapHealthChecks("/hc", new HealthCheckOptions
{
Predicate = _ => true,
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
});
endpoints.MapHealthChecks("/liveness", new HealthCheckOptions
{
Predicate = r => r.Name.Contains("self")
});
});
ConfigureEventBus(app);
}
private void ConfigureEventBus(IApplicationBuilder app)
{
var eventBus = app.ApplicationServices.GetRequiredService<IEventBus>();
eventBus.Subscribe<OrderStatusChangedToAwaitingCouponValidationIntegrationEvent, IIntegrationEventHandler<OrderStatusChangedToAwaitingCouponValidationIntegrationEvent>>();
eventBus.Subscribe<OrderStatusChangedToCancelledIntegrationEvent, IIntegrationEventHandler<OrderStatusChangedToCancelledIntegrationEvent>>();
}
}
}

+ 18
- 0
src/Services/Coupon/Coupon.API/appsettings.Development.json View File

@ -0,0 +1,18 @@
{
"ConnectionString": "mongodb://localhost:27017",
"CouponMongoDatabase": "CouponDb",
"Serilog": {
"MinimumLevel": {
"Default": "Debug",
"Override": {
"Microsoft": "Warning",
"Microsoft.eShopOnContainers": "Debug",
"System": "Warning"
}
}
},
"IdentityUrlExternal": "http://localhost:5105",
"IdentityUrl": "http://localhost:5105",
"AzureServiceBusEnabled": false,
"EventBusConnection": "localhost"
}

+ 28
- 0
src/Services/Coupon/Coupon.API/appsettings.json View File

@ -0,0 +1,28 @@
{
"ConnectionString": null,
"CouponMongoDatabase": "CouponDb",
"UseCustomizationData": false,
"Serilog": {
"SeqServerUrl": null,
"LogstashUrl": null,
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"Microsoft.eShopOnContainers": "Information",
"System": "Warning"
}
}
},
"SubscriptionClientName": "Coupon",
"ApplicationInsights": {
"InstrumentationKey": ""
},
"EventBusRetryCount": 5,
"UseVault": false,
"Vault": {
"Name": "eshop",
"ClientId": "your-client-id",
"ClientSecret": "your-client-secret"
}
}

+ 1
- 0
src/Services/Identity/Identity.API/Dockerfile View File

@ -34,6 +34,7 @@ COPY "Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj" "Service
COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj"
COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj" COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj"
COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj"
COPY "Services/Coupon/Coupon.API/Coupon.API.csproj" "Services/Coupon/Coupon.API/Coupon.API.csproj"
COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj"
COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj" COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj"
COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj" COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj"


+ 1
- 0
src/Services/Ordering/Ordering.API/Dockerfile View File

@ -34,6 +34,7 @@ COPY "Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj" "Service
COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj"
COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj" COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj"
COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj"
COPY "Services/Coupon/Coupon.API/Coupon.API.csproj" "Services/Coupon/Coupon.API/Coupon.API.csproj"
COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj"
COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj" COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj"
COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj" COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj"


+ 1
- 0
src/Services/Ordering/Ordering.BackgroundTasks/Dockerfile View File

@ -34,6 +34,7 @@ COPY "Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj" "Service
COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj"
COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj" COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj"
COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj"
COPY "Services/Coupon/Coupon.API/Coupon.API.csproj" "Services/Coupon/Coupon.API/Coupon.API.csproj"
COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj"
COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj" COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj"
COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj" COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj"


+ 1
- 0
src/Services/Ordering/Ordering.SignalrHub/Dockerfile View File

@ -34,6 +34,7 @@ COPY "Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj" "Service
COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj"
COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj" COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj"
COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj"
COPY "Services/Coupon/Coupon.API/Coupon.API.csproj" "Services/Coupon/Coupon.API/Coupon.API.csproj"
COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj"
COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj" COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj"
COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj" COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj"


+ 1
- 0
src/Services/Payment/Payment.API/Dockerfile View File

@ -34,6 +34,7 @@ COPY "Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj" "Service
COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj"
COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj" COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj"
COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj"
COPY "Services/Coupon/Coupon.API/Coupon.API.csproj" "Services/Coupon/Coupon.API/Coupon.API.csproj"
COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj"
COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj" COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj"
COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj" COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj"


+ 1
- 0
src/Services/Webhooks/Webhooks.API/Dockerfile View File

@ -34,6 +34,7 @@ COPY "Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj" "Service
COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj"
COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj" COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj"
COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj"
COPY "Services/Coupon/Coupon.API/Coupon.API.csproj" "Services/Coupon/Coupon.API/Coupon.API.csproj"
COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj"
COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj" COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj"
COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj" COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj"


+ 1
- 0
src/Web/WebMVC/Dockerfile View File

@ -34,6 +34,7 @@ COPY "Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj" "Service
COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj"
COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj" COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj"
COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj"
COPY "Services/Coupon/Coupon.API/Coupon.API.csproj" "Services/Coupon/Coupon.API/Coupon.API.csproj"
COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj"
COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj" COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj"
COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj" COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj"


+ 9787
- 7838
src/Web/WebSPA/Client/yarn.lock
File diff suppressed because it is too large
View File


+ 7
- 0
src/Web/WebSPA/Dockerfile View File

@ -3,6 +3,12 @@
ARG NODE_IMAGE=node:12.0 ARG NODE_IMAGE=node:12.0
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app WORKDIR /app
RUN apt-get update
RUN apt-get -y install curl gnupg
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get -y install nodejs
RUN npm install
RUN npm -v
EXPOSE 80 EXPOSE 80
FROM ${NODE_IMAGE} as node-build FROM ${NODE_IMAGE} as node-build
@ -45,6 +51,7 @@ COPY "Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj" "Service
COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj"
COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj" COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj"
COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj"
COPY "Services/Coupon/Coupon.API/Coupon.API.csproj" "Services/Coupon/Coupon.API/Coupon.API.csproj"
COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj"
COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj" COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj"
COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj" COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj"


+ 1
- 0
src/Web/WebStatus/Dockerfile View File

@ -34,6 +34,7 @@ COPY "Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj" "Service
COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj"
COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj" COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj"
COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj"
COPY "Services/Coupon/Coupon.API/Coupon.API.csproj" "Services/Coupon/Coupon.API/Coupon.API.csproj"
COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj"
COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj" COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj"
COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj" COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj"


+ 1
- 0
src/Web/WebhookClient/Dockerfile View File

@ -35,6 +35,7 @@ COPY "Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj" "Service
COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj"
COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj" COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj"
COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj"
COPY "Services/Coupon/Coupon.API/Coupon.API.csproj" "Services/Coupon/Coupon.API/Coupon.API.csproj"
COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj"
COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj" COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj"
COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj" COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj"


+ 20
- 1
src/docker-compose.override.yml View File

@ -173,6 +173,23 @@ services:
ports: ports:
- "5113:80" - "5113:80"
coupon-api:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://0.0.0.0:80
- EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq}
- EventBusUserName=${ESHOP_SERVICE_BUS_USERNAME}
- EventBusPassword=${ESHOP_SERVICE_BUS_PASSWORD}
- AzureServiceBusEnabled=False
- ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY}
- OrchestratorType=${ORCHESTRATOR_TYPE}
- PORT=80
- PATH_BASE=/catalog-api
- ConnectionString=mongodb://nosqldata:27017
ports:
- "5106:80"
- "9106:81"
mobileshoppingapigw: mobileshoppingapigw:
volumes: volumes:
- ./ApiGateways/Envoy/config/mobileshopping:/etc/envoy - ./ApiGateways/Envoy/config/mobileshopping:/etc/envoy
@ -265,6 +282,8 @@ services:
- HealthChecksUI__HealthChecks__9__Uri=http://ordering-signalrhub/hc - HealthChecksUI__HealthChecks__9__Uri=http://ordering-signalrhub/hc
- HealthChecksUI__HealthChecks__10__Name=Ordering HTTP Background Check - HealthChecksUI__HealthChecks__10__Name=Ordering HTTP Background Check
- HealthChecksUI__HealthChecks__10__Uri=http://ordering-backgroundtasks/hc - HealthChecksUI__HealthChecks__10__Uri=http://ordering-backgroundtasks/hc
- HealthChecksUI__HealthChecks__11__Name=Coupon HTTP Check
- HealthChecksUI__HealthChecks__11__Uri=http://coupon-api/hc
- ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY} - ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY}
- OrchestratorType=${ORCHESTRATOR_TYPE} - OrchestratorType=${ORCHESTRATOR_TYPE}
ports: ports:
@ -272,7 +291,7 @@ services:
webspa: webspa:
environment: environment:
- ASPNETCORE_ENVIRONMENT=Production
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://0.0.0.0:80 - ASPNETCORE_URLS=http://0.0.0.0:80
- IdentityUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 - IdentityUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105
- PurchaseUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5202 - PurchaseUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5202


+ 14
- 0
src/docker-compose.prod.yml View File

@ -171,6 +171,20 @@ services:
ports: ports:
- "80" # The API Gateway redirects and access through the internal port (80). - "80" # The API Gateway redirects and access through the internal port (80).
coupon-api:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://0.0.0.0:80
- EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq}
- EventBusUserName=${ESHOP_SERVICE_BUS_USERNAME}
- EventBusPassword=${ESHOP_SERVICE_BUS_PASSWORD}
- AzureServiceBusEnabled=False
- ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY}
- OrchestratorType=${ORCHESTRATOR_TYPE}
- ConnectionString=mongodb://nosqldata:27017
ports:
- "80" # The API Gateway redirects and access through the internal port (80).
sqldata: sqldata:
environment: environment:
- SA_PASSWORD=Pass@word - SA_PASSWORD=Pass@word


+ 9
- 0
src/docker-compose.yml View File

@ -78,6 +78,15 @@ services:
depends_on: depends_on:
- sqldata - sqldata
coupon-api:
image: ${REGISTRY:-eshop}/coupon.api:${PLATFORM:-linux}-${TAG:-latest}
build:
context: .
dockerfile: Services/Coupon/Coupon.API/Dockerfile
depends_on:
- nosqldata
- rabbitmq
mobileshoppingapigw: mobileshoppingapigw:
image: envoyproxy/envoy:v1.11.1 image: envoyproxy/envoy:v1.11.1


+ 58
- 4
src/eShopOnContainers-ServicesAndWebApps.sln View File

@ -1,7 +1,7 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29020.237
# Visual Studio Version 17
VisualStudioVersion = 17.4.33122.133
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{FEA0C318-FFED-4D39-8781-265718CA43DD}" Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{FEA0C318-FFED-4D39-8781-265718CA43DD}"
EndProject EndProject
@ -124,6 +124,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{373D8AA1
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EventBus.Tests", "BuildingBlocks\EventBus\EventBus.Tests\EventBus.Tests.csproj", "{95D735BE-2899-4495-BE3F-2600E93B4E3C}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EventBus.Tests", "BuildingBlocks\EventBus\EventBus.Tests\EventBus.Tests.csproj", "{95D735BE-2899-4495-BE3F-2600E93B4E3C}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Coupon", "Coupon", "{F7874ADA-2D4D-40CB-8ED2-A17839B3FF2A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Coupon.API", "Services\Coupon\Coupon.API\Coupon.API.csproj", "{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Ad-Hoc|Any CPU = Ad-Hoc|Any CPU Ad-Hoc|Any CPU = Ad-Hoc|Any CPU
@ -450,8 +454,8 @@ Global
{F16E3C6A-1C94-4EAB-BE91-099618060B68}.AppStore|x64.Build.0 = Release|Any CPU {F16E3C6A-1C94-4EAB-BE91-099618060B68}.AppStore|x64.Build.0 = Release|Any CPU
{F16E3C6A-1C94-4EAB-BE91-099618060B68}.AppStore|x86.ActiveCfg = Release|Any CPU {F16E3C6A-1C94-4EAB-BE91-099618060B68}.AppStore|x86.ActiveCfg = Release|Any CPU
{F16E3C6A-1C94-4EAB-BE91-099618060B68}.AppStore|x86.Build.0 = Release|Any CPU {F16E3C6A-1C94-4EAB-BE91-099618060B68}.AppStore|x86.Build.0 = Release|Any CPU
{F16E3C6A-1C94-4EAB-BE91-099618060B68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F16E3C6A-1C94-4EAB-BE91-099618060B68}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F16E3C6A-1C94-4EAB-BE91-099618060B68}.Debug|Any CPU.ActiveCfg = Release|Any CPU
{F16E3C6A-1C94-4EAB-BE91-099618060B68}.Debug|Any CPU.Build.0 = Release|Any CPU
{F16E3C6A-1C94-4EAB-BE91-099618060B68}.Debug|ARM.ActiveCfg = Debug|Any CPU {F16E3C6A-1C94-4EAB-BE91-099618060B68}.Debug|ARM.ActiveCfg = Debug|Any CPU
{F16E3C6A-1C94-4EAB-BE91-099618060B68}.Debug|ARM.Build.0 = Debug|Any CPU {F16E3C6A-1C94-4EAB-BE91-099618060B68}.Debug|ARM.Build.0 = Debug|Any CPU
{F16E3C6A-1C94-4EAB-BE91-099618060B68}.Debug|iPhone.ActiveCfg = Debug|Any CPU {F16E3C6A-1C94-4EAB-BE91-099618060B68}.Debug|iPhone.ActiveCfg = Debug|Any CPU
@ -1530,6 +1534,54 @@ Global
{95D735BE-2899-4495-BE3F-2600E93B4E3C}.Release|x64.Build.0 = Release|Any CPU {95D735BE-2899-4495-BE3F-2600E93B4E3C}.Release|x64.Build.0 = Release|Any CPU
{95D735BE-2899-4495-BE3F-2600E93B4E3C}.Release|x86.ActiveCfg = Release|Any CPU {95D735BE-2899-4495-BE3F-2600E93B4E3C}.Release|x86.ActiveCfg = Release|Any CPU
{95D735BE-2899-4495-BE3F-2600E93B4E3C}.Release|x86.Build.0 = Release|Any CPU {95D735BE-2899-4495-BE3F-2600E93B4E3C}.Release|x86.Build.0 = Release|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Ad-Hoc|x64.Build.0 = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.AppStore|ARM.ActiveCfg = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.AppStore|ARM.Build.0 = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.AppStore|iPhone.Build.0 = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.AppStore|x64.ActiveCfg = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.AppStore|x64.Build.0 = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.AppStore|x86.ActiveCfg = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.AppStore|x86.Build.0 = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Debug|ARM.ActiveCfg = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Debug|ARM.Build.0 = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Debug|iPhone.Build.0 = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Debug|x64.ActiveCfg = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Debug|x64.Build.0 = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Debug|x86.ActiveCfg = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Debug|x86.Build.0 = Debug|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Release|Any CPU.Build.0 = Release|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Release|ARM.ActiveCfg = Release|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Release|ARM.Build.0 = Release|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Release|iPhone.ActiveCfg = Release|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Release|iPhone.Build.0 = Release|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Release|x64.ActiveCfg = Release|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Release|x64.Build.0 = Release|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Release|x86.ActiveCfg = Release|Any CPU
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -1588,6 +1640,8 @@ Global
{B62E859F-825E-4C8B-93EC-5966EACFD026} = {798BFC44-2CCD-45FA-B37A-5173B03C2B30} {B62E859F-825E-4C8B-93EC-5966EACFD026} = {798BFC44-2CCD-45FA-B37A-5173B03C2B30}
{373D8AA1-36BE-49EC-89F0-6CB736666285} = {807BB76E-B2BB-47A2-A57B-3D1B20FF5E7F} {373D8AA1-36BE-49EC-89F0-6CB736666285} = {807BB76E-B2BB-47A2-A57B-3D1B20FF5E7F}
{95D735BE-2899-4495-BE3F-2600E93B4E3C} = {373D8AA1-36BE-49EC-89F0-6CB736666285} {95D735BE-2899-4495-BE3F-2600E93B4E3C} = {373D8AA1-36BE-49EC-89F0-6CB736666285}
{F7874ADA-2D4D-40CB-8ED2-A17839B3FF2A} = {91CF7717-08AB-4E65-B10E-0B426F01E2E8}
{45CCC69D-07C3-48DC-80F0-49DE7751EE9A} = {F7874ADA-2D4D-40CB-8ED2-A17839B3FF2A}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {25728519-5F0F-4973-8A64-0A81EB4EA8D9} SolutionGuid = {25728519-5F0F-4973-8A64-0A81EB4EA8D9}


Loading…
Cancel
Save