Merge pull request #1559 from borjasanes/feature/webapps-net5-migration
Feature/webapps net5 migration
This commit is contained in:
commit
3434459888
@ -1,76 +0,0 @@
|
|||||||
using Grpc.Core;
|
|
||||||
using Grpc.Net.Client;
|
|
||||||
using Serilog;
|
|
||||||
using System;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services
|
|
||||||
{
|
|
||||||
public static class GrpcCallerService
|
|
||||||
{
|
|
||||||
public static async Task<TResponse> CallService<TResponse>(string urlGrpc, Func<GrpcChannel, Task<TResponse>> func)
|
|
||||||
{
|
|
||||||
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
|
|
||||||
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", true);
|
|
||||||
|
|
||||||
var channel = GrpcChannel.ForAddress(urlGrpc);
|
|
||||||
|
|
||||||
/*
|
|
||||||
using var httpClientHandler = new HttpClientHandler
|
|
||||||
{
|
|
||||||
ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return true; }
|
|
||||||
};
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
Log.Information("Creating grpc client base address urlGrpc ={@urlGrpc}, BaseAddress={@BaseAddress} ", urlGrpc, channel.Target);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return await func(channel);
|
|
||||||
}
|
|
||||||
catch (RpcException e)
|
|
||||||
{
|
|
||||||
Log.Error("Error calling via grpc: {Status} - {Message}", e.Status, e.Message);
|
|
||||||
return default;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", false);
|
|
||||||
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static async Task CallService(string urlGrpc, Func<GrpcChannel, Task> func)
|
|
||||||
{
|
|
||||||
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
|
|
||||||
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", true);
|
|
||||||
|
|
||||||
/*
|
|
||||||
using var httpClientHandler = new HttpClientHandler
|
|
||||||
{
|
|
||||||
ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return true; }
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
|
|
||||||
var channel = GrpcChannel.ForAddress(urlGrpc);
|
|
||||||
|
|
||||||
Log.Debug("Creating grpc client base address {@httpClient.BaseAddress} ", channel.Target);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await func(channel);
|
|
||||||
}
|
|
||||||
catch (RpcException e)
|
|
||||||
{
|
|
||||||
Log.Error("Error calling via grpc: {Status} - {Message}", e.Status, e.Message);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", false);
|
|
||||||
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,78 +0,0 @@
|
|||||||
using Grpc.Core;
|
|
||||||
using Grpc.Net.Client;
|
|
||||||
using Serilog;
|
|
||||||
using System;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services
|
|
||||||
{
|
|
||||||
public static class GrpcCallerService
|
|
||||||
{
|
|
||||||
public static async Task<TResponse> CallService<TResponse>(string urlGrpc, Func<GrpcChannel, Task<TResponse>> func)
|
|
||||||
{
|
|
||||||
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
|
|
||||||
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", true);
|
|
||||||
|
|
||||||
var channel = GrpcChannel.ForAddress(urlGrpc);
|
|
||||||
|
|
||||||
/*
|
|
||||||
using var httpClientHandler = new HttpClientHandler
|
|
||||||
{
|
|
||||||
ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return true; }
|
|
||||||
};
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
Log.Information("Creating grpc client base address urlGrpc ={@urlGrpc}, BaseAddress={@BaseAddress} ", urlGrpc, channel.Target);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return await func(channel);
|
|
||||||
}
|
|
||||||
catch (RpcException e)
|
|
||||||
{
|
|
||||||
Log.Error("Error calling via grpc: {Status} - {Message}", e.Status, e.Message);
|
|
||||||
return default;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", false);
|
|
||||||
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static async Task CallService(string urlGrpc, Func<GrpcChannel, Task> func)
|
|
||||||
{
|
|
||||||
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
|
|
||||||
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", true);
|
|
||||||
|
|
||||||
/*
|
|
||||||
using var httpClientHandler = new HttpClientHandler
|
|
||||||
{
|
|
||||||
ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return true; }
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
|
|
||||||
var channel = GrpcChannel.ForAddress(urlGrpc);
|
|
||||||
|
|
||||||
Log.Debug("Creating grpc client base address {@httpClient.BaseAddress} ", channel.Target);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await func(channel);
|
|
||||||
}
|
|
||||||
catch (RpcException e)
|
|
||||||
{
|
|
||||||
Log.Error("Error calling via grpc: {Status} - {Message}", e.Status, e.Message);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", false);
|
|
||||||
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +1,11 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.0" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.0" />
|
<PackageReference Include="Microsoft.Extensions.Http" Version="5.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.1</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<RootNamespace>Microsoft.eShopOnContainers.BuildingBlocks.EventBus</RootNamespace>
|
<RootNamespace>Microsoft.eShopOnContainers.BuildingBlocks.EventBus</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events
|
||||||
{
|
{
|
||||||
public class IntegrationEvent
|
public record IntegrationEvent
|
||||||
{
|
{
|
||||||
public IntegrationEvent()
|
public IntegrationEvent()
|
||||||
{
|
{
|
||||||
@ -19,9 +19,9 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events
|
|||||||
}
|
}
|
||||||
|
|
||||||
[JsonProperty]
|
[JsonProperty]
|
||||||
public Guid Id { get; private set; }
|
public Guid Id { get; private init; }
|
||||||
|
|
||||||
[JsonProperty]
|
[JsonProperty]
|
||||||
public DateTime CreationDate { get; private set; }
|
public DateTime CreationDate { get; private init; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ
|
|||||||
private async Task Consumer_Received(object sender, BasicDeliverEventArgs eventArgs)
|
private async Task Consumer_Received(object sender, BasicDeliverEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
var eventName = eventArgs.RoutingKey;
|
var eventName = eventArgs.RoutingKey;
|
||||||
var message = Encoding.UTF8.GetString(eventArgs.Body);
|
var message = Encoding.UTF8.GetString(eventArgs.Body.Span);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.1</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<RootNamespace>Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ</RootNamespace>
|
<RootNamespace>Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Autofac" Version="4.9.4" />
|
<PackageReference Include="Autofac" Version="6.1.0" />
|
||||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
<PackageReference Include="Polly" Version="7.2.0" />
|
<PackageReference Include="Polly" Version="7.2.1" />
|
||||||
<PackageReference Include="RabbitMQ.Client" Version="6.0.0-rc1" />
|
<PackageReference Include="RabbitMQ.Client" Version="6.2.1" />
|
||||||
<PackageReference Include="System.ValueTuple" Version="4.6.0-preview1-26829-04" />
|
<PackageReference Include="System.ValueTuple" Version="4.6.0-preview1-26829-04" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.1</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<RootNamespace>Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus</RootNamespace>
|
<RootNamespace>Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Autofac" Version="4.9.4" />
|
<PackageReference Include="Autofac" Version="6.1.0" />
|
||||||
<PackageReference Include="Microsoft.Azure.ServiceBus" Version="4.1.1" />
|
<PackageReference Include="Microsoft.Azure.ServiceBus" Version="5.1.0" />
|
||||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.1</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<RootNamespace>Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF</RootNamespace>
|
<RootNamespace>Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.0">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.1">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.0" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.1" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.0" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.1" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.0" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.1" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -1,22 +1,23 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>
|
<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="3.0.0-preview4-19123-01" />
|
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="3.0.0-preview4-19123-01" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.0">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.1">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.0" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.1" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.0" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.1" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.0" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.1" />
|
||||||
<PackageReference Include="Microsoft.NETCore.Platforms" Version="3.1.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="5.0.0" />
|
||||||
<PackageReference Include="Polly" Version="7.2.0" />
|
<PackageReference Include="Microsoft.NETCore.Platforms" Version="5.0.0" />
|
||||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.0" />
|
<PackageReference Include="Polly" Version="7.2.1" />
|
||||||
|
<PackageReference Include="System.Data.SqlClient" Version="4.8.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.16.0" />
|
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.16.0" />
|
||||||
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.16.0" />
|
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.16.0" />
|
||||||
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.1.3" />
|
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.1.3" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.1" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.1" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.1" />
|
||||||
|
@ -5,9 +5,9 @@ namespace Basket.API.IntegrationEvents.Events
|
|||||||
// Integration Events notes:
|
// Integration Events notes:
|
||||||
// An Event is “something that has happened in the past”, therefore its name has to be
|
// An Event is “something that has happened in the past”, therefore its name has to be
|
||||||
// An Integration Event is an event that can cause side effects to other microsrvices, Bounded-Contexts or external systems.
|
// An Integration Event is an event that can cause side effects to other microsrvices, Bounded-Contexts or external systems.
|
||||||
public class OrderStartedIntegrationEvent : IntegrationEvent
|
public record OrderStartedIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public string UserId { get; set; }
|
public string UserId { get; init; }
|
||||||
|
|
||||||
public OrderStartedIntegrationEvent(string userId)
|
public OrderStartedIntegrationEvent(string userId)
|
||||||
=> UserId = userId;
|
=> UserId = userId;
|
||||||
|
@ -5,13 +5,13 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.Even
|
|||||||
// Integration Events notes:
|
// Integration Events notes:
|
||||||
// An Event is “something that has happened in the past”, therefore its name has to be
|
// An Event is “something that has happened in the past”, therefore its name has to be
|
||||||
// An Integration Event is an event that can cause side effects to other microsrvices, Bounded-Contexts or external systems.
|
// An Integration Event is an event that can cause side effects to other microsrvices, Bounded-Contexts or external systems.
|
||||||
public class ProductPriceChangedIntegrationEvent : IntegrationEvent
|
public record ProductPriceChangedIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int ProductId { get; private set; }
|
public int ProductId { get; private init; }
|
||||||
|
|
||||||
public decimal NewPrice { get; private set; }
|
public decimal NewPrice { get; private init; }
|
||||||
|
|
||||||
public decimal OldPrice { get; private set; }
|
public decimal OldPrice { get; private init; }
|
||||||
|
|
||||||
public ProductPriceChangedIntegrationEvent(int productId, decimal newPrice, decimal oldPrice)
|
public ProductPriceChangedIntegrationEvent(int productId, decimal newPrice, decimal oldPrice)
|
||||||
{
|
{
|
||||||
|
@ -4,37 +4,37 @@ using System;
|
|||||||
|
|
||||||
namespace Basket.API.IntegrationEvents.Events
|
namespace Basket.API.IntegrationEvents.Events
|
||||||
{
|
{
|
||||||
public class UserCheckoutAcceptedIntegrationEvent : IntegrationEvent
|
public record UserCheckoutAcceptedIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public string UserId { get; }
|
public string UserId { get; }
|
||||||
|
|
||||||
public string UserName { get; }
|
public string UserName { get; }
|
||||||
|
|
||||||
public int OrderNumber { get; set; }
|
public int OrderNumber { get; init; }
|
||||||
|
|
||||||
public string City { get; set; }
|
public string City { get; init; }
|
||||||
|
|
||||||
public string Street { get; set; }
|
public string Street { get; init; }
|
||||||
|
|
||||||
public string State { get; set; }
|
public string State { get; init; }
|
||||||
|
|
||||||
public string Country { get; set; }
|
public string Country { get; init; }
|
||||||
|
|
||||||
public string ZipCode { get; set; }
|
public string ZipCode { get; init; }
|
||||||
|
|
||||||
public string CardNumber { get; set; }
|
public string CardNumber { get; init; }
|
||||||
|
|
||||||
public string CardHolderName { get; set; }
|
public string CardHolderName { get; init; }
|
||||||
|
|
||||||
public DateTime CardExpiration { get; set; }
|
public DateTime CardExpiration { get; init; }
|
||||||
|
|
||||||
public string CardSecurityNumber { get; set; }
|
public string CardSecurityNumber { get; init; }
|
||||||
|
|
||||||
public int CardTypeId { get; set; }
|
public int CardTypeId { get; init; }
|
||||||
|
|
||||||
public string Buyer { get; set; }
|
public string Buyer { get; init; }
|
||||||
|
|
||||||
public Guid RequestId { get; set; }
|
public Guid RequestId { get; init; }
|
||||||
|
|
||||||
public CustomerBasket Basket { get; }
|
public CustomerBasket Basket { get; }
|
||||||
|
|
||||||
|
@ -2,29 +2,29 @@
|
|||||||
|
|
||||||
namespace Basket.API.Model
|
namespace Basket.API.Model
|
||||||
{
|
{
|
||||||
public record BasketCheckout
|
public class BasketCheckout
|
||||||
{
|
{
|
||||||
public string City { get; init; }
|
public string City { get; set; }
|
||||||
|
|
||||||
public string Street { get; init; }
|
public string Street { get; set; }
|
||||||
|
|
||||||
public string State { get; init; }
|
public string State { get; set; }
|
||||||
|
|
||||||
public string Country { get; init; }
|
public string Country { get; set; }
|
||||||
|
|
||||||
public string ZipCode { get; init; }
|
public string ZipCode { get; set; }
|
||||||
|
|
||||||
public string CardNumber { get; init; }
|
public string CardNumber { get; set; }
|
||||||
|
|
||||||
public string CardHolderName { get; init; }
|
public string CardHolderName { get; set; }
|
||||||
|
|
||||||
public DateTime CardExpiration { get; init; }
|
public DateTime CardExpiration { get; set; }
|
||||||
|
|
||||||
public string CardSecurityNumber { get; init; }
|
public string CardSecurityNumber { get; set; }
|
||||||
|
|
||||||
public int CardTypeId { get; init; }
|
public int CardTypeId { get; set; }
|
||||||
|
|
||||||
public string Buyer { get; init; }
|
public string Buyer { get; set; }
|
||||||
|
|
||||||
public Guid RequestId { get; set; }
|
public Guid RequestId { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -3,15 +3,15 @@ using System.ComponentModel.DataAnnotations;
|
|||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Services.Basket.API.Model
|
namespace Microsoft.eShopOnContainers.Services.Basket.API.Model
|
||||||
{
|
{
|
||||||
public record BasketItem : IValidatableObject
|
public class BasketItem : IValidatableObject
|
||||||
{
|
{
|
||||||
public string Id { get; init; }
|
public string Id { get; set; }
|
||||||
public int ProductId { get; init; }
|
public int ProductId { get; set; }
|
||||||
public string ProductName { get; init; }
|
public string ProductName { get; set; }
|
||||||
public decimal UnitPrice { get; set; }
|
public decimal UnitPrice { get; set; }
|
||||||
public decimal OldUnitPrice { get; set; }
|
public decimal OldUnitPrice { get; set; }
|
||||||
public int Quantity { get; init; }
|
public int Quantity { get; set; }
|
||||||
public string PictureUrl { get; init; }
|
public string PictureUrl { get; set; }
|
||||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||||
{
|
{
|
||||||
var results = new List<ValidationResult>();
|
var results = new List<ValidationResult>();
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Services.Basket.API.Model
|
namespace Microsoft.eShopOnContainers.Services.Basket.API.Model
|
||||||
{
|
{
|
||||||
public record CustomerBasket
|
public class CustomerBasket
|
||||||
{
|
{
|
||||||
public string BuyerId { get; init; }
|
public string BuyerId { get; set; }
|
||||||
|
|
||||||
public List<BasketItem> Items { get; set; } = new List<BasketItem>();
|
public List<BasketItem> Items { get; set; } = new List<BasketItem>();
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
using BuildingBlocks.EventBus.Events;
|
using BuildingBlocks.EventBus.Events;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
public class OrderStatusChangedToAwaitingValidationIntegrationEvent : IntegrationEvent
|
public record OrderStatusChangedToAwaitingValidationIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int OrderId { get; }
|
public int OrderId { get; }
|
||||||
public IEnumerable<OrderStockItem> OrderStockItems { get; }
|
public IEnumerable<OrderStockItem> OrderStockItems { get; }
|
||||||
@ -16,7 +16,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class OrderStockItem
|
public record OrderStockItem
|
||||||
{
|
{
|
||||||
public int ProductId { get; }
|
public int ProductId { get; }
|
||||||
public int Units { get; }
|
public int Units { get; }
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
|
|
||||||
public class OrderStatusChangedToPaidIntegrationEvent : IntegrationEvent
|
public record OrderStatusChangedToPaidIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int OrderId { get; }
|
public int OrderId { get; }
|
||||||
public IEnumerable<OrderStockItem> OrderStockItems { get; }
|
public IEnumerable<OrderStockItem> OrderStockItems { get; }
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
using BuildingBlocks.EventBus.Events;
|
using BuildingBlocks.EventBus.Events;
|
||||||
|
|
||||||
public class OrderStockConfirmedIntegrationEvent : IntegrationEvent
|
public record OrderStockConfirmedIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int OrderId { get; }
|
public int OrderId { get; }
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
using BuildingBlocks.EventBus.Events;
|
using BuildingBlocks.EventBus.Events;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
public class OrderStockRejectedIntegrationEvent : IntegrationEvent
|
public record OrderStockRejectedIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int OrderId { get; }
|
public int OrderId { get; }
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ConfirmedOrderStockItem
|
public record ConfirmedOrderStockItem
|
||||||
{
|
{
|
||||||
public int ProductId { get; }
|
public int ProductId { get; }
|
||||||
public bool HasStock { get; }
|
public bool HasStock { get; }
|
||||||
|
@ -5,13 +5,13 @@
|
|||||||
// Integration Events notes:
|
// Integration Events notes:
|
||||||
// An Event is “something that has happened in the past”, therefore its name has to be past tense
|
// An Event is “something that has happened in the past”, therefore its name has to be past tense
|
||||||
// An Integration Event is an event that can cause side effects to other microservices, Bounded-Contexts or external systems.
|
// An Integration Event is an event that can cause side effects to other microservices, Bounded-Contexts or external systems.
|
||||||
public class ProductPriceChangedIntegrationEvent : IntegrationEvent
|
public record ProductPriceChangedIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int ProductId { get; private set; }
|
public int ProductId { get; private init; }
|
||||||
|
|
||||||
public decimal NewPrice { get; private set; }
|
public decimal NewPrice { get; private init; }
|
||||||
|
|
||||||
public decimal OldPrice { get; private set; }
|
public decimal OldPrice { get; private init; }
|
||||||
|
|
||||||
public ProductPriceChangedIntegrationEvent(int productId, decimal newPrice, decimal oldPrice)
|
public ProductPriceChangedIntegrationEvent(int productId, decimal newPrice, decimal oldPrice)
|
||||||
{
|
{
|
||||||
|
@ -33,10 +33,10 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="5.0.1" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.1.0" />
|
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="5.0.1" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
@ -7,11 +7,11 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.0" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.1" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
|
||||||
<PackageReference Include="Microsoft.NETCore.Platforms" Version="3.1.0" />
|
<PackageReference Include="Microsoft.NETCore.Platforms" Version="5.0.0" />
|
||||||
<PackageReference Include="Moq" Version="4.13.1" />
|
<PackageReference Include="Moq" Version="4.15.2" />
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
@ -16,39 +16,40 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="3.0.0" />
|
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="3.2.0" />
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="3.0.0" />
|
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="3.1.2" />
|
||||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="5.0.1" />
|
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
|
||||||
<PackageReference Include="IdentityServer4.AspNetIdentity" Version="3.0.2" />
|
<PackageReference Include="IdentityServer4.AspNetIdentity" Version="3.0.2" />
|
||||||
<PackageReference Include="IdentityServer4.EntityFramework.Storage" Version="3.0.2" />
|
<PackageReference Include="IdentityServer4.EntityFramework.Storage" Version="3.0.2" />
|
||||||
<PackageReference Include="IdentityServer4.EntityFramework" Version="3.0.2" />
|
<PackageReference Include="IdentityServer4.EntityFramework" Version="3.0.2" />
|
||||||
<PackageReference Include="IdentityServer4.Storage" Version="3.0.2" />
|
<PackageReference Include="IdentityServer4.Storage" Version="3.0.2" />
|
||||||
<PackageReference Include="IdentityServer4" Version="3.0.2" />
|
<PackageReference Include="IdentityServer4" Version="3.0.2" />
|
||||||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.12.0" />
|
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.16.0" />
|
||||||
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.12.0" />
|
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.16.0" />
|
||||||
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.1.1" />
|
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.1.3" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.DataProtection.Redis" Version="2.2.0-preview3-35458" />
|
<PackageReference Include="Microsoft.AspNetCore.DataProtection.Redis" Version="2.2.0-preview3-35458" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.1.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.1.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.0" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.0">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.1">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.0" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.1" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.0" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="3.1.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="3.1.10" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="3.1.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="5.0.1" />
|
||||||
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="2.0.96" />
|
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="2.1.113" />
|
||||||
<PackageReference Include="Polly" Version="7.2.0" />
|
<PackageReference Include="Polly" Version="7.2.1" />
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="3.2.0" />
|
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
|
||||||
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.3" />
|
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.3" />
|
||||||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.1-dev-00216" />
|
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.1-dev-00216" />
|
||||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.0-dev-00834" />
|
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.0-dev-00834" />
|
||||||
<PackageReference Include="Serilog.Sinks.Http" Version="5.2.0" />
|
<PackageReference Include="Serilog.Sinks.Http" Version="7.2.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.Seq" Version="4.1.0-dev-00166" />
|
<PackageReference Include="Serilog.Sinks.Seq" Version="4.1.0-dev-00166" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc5" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
|
||||||
|
<PackageReference Include="System.Data.SqlClient" Version="4.8.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -128,7 +128,6 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API
|
|||||||
if (env.IsDevelopment())
|
if (env.IsDevelopment())
|
||||||
{
|
{
|
||||||
app.UseDeveloperExceptionPage();
|
app.UseDeveloperExceptionPage();
|
||||||
app.UseDatabaseErrorPage();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@ namespace Ordering.API.Application.Commands
|
|||||||
{
|
{
|
||||||
|
|
||||||
[DataMember]
|
[DataMember]
|
||||||
public int OrderNumber { get; private set; }
|
public int OrderNumber { get; set; }
|
||||||
public CancelOrderCommand()
|
public CancelOrderCommand()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
|
|
||||||
public class GracePeriodConfirmedIntegrationEvent : IntegrationEvent
|
public record GracePeriodConfirmedIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int OrderId { get; }
|
public int OrderId { get; }
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
|
|
||||||
public class OrderPaymentFailedIntegrationEvent : IntegrationEvent
|
public record OrderPaymentFailedIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int OrderId { get; }
|
public int OrderId { get; }
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
|
|
||||||
public class OrderPaymentSucceededIntegrationEvent : IntegrationEvent
|
public record OrderPaymentSucceededIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int OrderId { get; }
|
public int OrderId { get; }
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ namespace Ordering.API.Application.IntegrationEvents.Events
|
|||||||
// Integration Events notes:
|
// Integration Events notes:
|
||||||
// An Event is “something that has happened in the past”, therefore its name has to be
|
// An Event is “something that has happened in the past”, therefore its name has to be
|
||||||
// An Integration Event is an event that can cause side effects to other microsrvices, Bounded-Contexts or external systems.
|
// An Integration Event is an event that can cause side effects to other microsrvices, Bounded-Contexts or external systems.
|
||||||
public class OrderStartedIntegrationEvent : IntegrationEvent
|
public record OrderStartedIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public string UserId { get; set; }
|
public string UserId { get; set; }
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
|
|
||||||
public class OrderStatusChangedToAwaitingValidationIntegrationEvent : IntegrationEvent
|
public record OrderStatusChangedToAwaitingValidationIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int OrderId { get; }
|
public int OrderId { get; }
|
||||||
public string OrderStatus { get; }
|
public string OrderStatus { get; }
|
||||||
@ -20,7 +20,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class OrderStockItem
|
public record OrderStockItem
|
||||||
{
|
{
|
||||||
public int ProductId { get; }
|
public int ProductId { get; }
|
||||||
public int Units { get; }
|
public int Units { get; }
|
||||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Ordering.API.Application.IntegrationEvents.Events
|
namespace Ordering.API.Application.IntegrationEvents.Events
|
||||||
{
|
{
|
||||||
public class OrderStatusChangedToCancelledIntegrationEvent : IntegrationEvent
|
public record OrderStatusChangedToCancelledIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int OrderId { get; }
|
public int OrderId { get; }
|
||||||
public string OrderStatus { get; }
|
public string OrderStatus { get; }
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
|
|
||||||
public class OrderStatusChangedToPaidIntegrationEvent : IntegrationEvent
|
public record OrderStatusChangedToPaidIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int OrderId { get; }
|
public int OrderId { get; }
|
||||||
public string OrderStatus { get; }
|
public string OrderStatus { get; }
|
||||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Ordering.API.Application.IntegrationEvents.Events
|
namespace Ordering.API.Application.IntegrationEvents.Events
|
||||||
{
|
{
|
||||||
public class OrderStatusChangedToShippedIntegrationEvent : IntegrationEvent
|
public record OrderStatusChangedToShippedIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int OrderId { get; }
|
public int OrderId { get; }
|
||||||
public string OrderStatus { get; }
|
public string OrderStatus { get; }
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
|
|
||||||
public class OrderStatusChangedToStockConfirmedIntegrationEvent : IntegrationEvent
|
public record OrderStatusChangedToStockConfirmedIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int OrderId { get; }
|
public int OrderId { get; }
|
||||||
public string OrderStatus { get; }
|
public string OrderStatus { get; }
|
||||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Ordering.API.Application.IntegrationEvents.Events
|
namespace Ordering.API.Application.IntegrationEvents.Events
|
||||||
{
|
{
|
||||||
public class OrderStatusChangedToSubmittedIntegrationEvent : IntegrationEvent
|
public record OrderStatusChangedToSubmittedIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int OrderId { get; }
|
public int OrderId { get; }
|
||||||
public string OrderStatus { get; }
|
public string OrderStatus { get; }
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
|
|
||||||
public class OrderStockConfirmedIntegrationEvent : IntegrationEvent
|
public record OrderStockConfirmedIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int OrderId { get; }
|
public int OrderId { get; }
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
public class OrderStockRejectedIntegrationEvent : IntegrationEvent
|
public record OrderStockRejectedIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int OrderId { get; }
|
public int OrderId { get; }
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ConfirmedOrderStockItem
|
public record ConfirmedOrderStockItem
|
||||||
{
|
{
|
||||||
public int ProductId { get; }
|
public int ProductId { get; }
|
||||||
public bool HasStock { get; }
|
public bool HasStock { get; }
|
||||||
|
@ -4,7 +4,7 @@ using System;
|
|||||||
|
|
||||||
namespace Ordering.API.Application.IntegrationEvents.Events
|
namespace Ordering.API.Application.IntegrationEvents.Events
|
||||||
{
|
{
|
||||||
public class UserCheckoutAcceptedIntegrationEvent : IntegrationEvent
|
public record UserCheckoutAcceptedIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public string UserId { get; }
|
public string UserId { get; }
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.16.0" />
|
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.16.0" />
|
||||||
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.16.0" />
|
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.16.0" />
|
||||||
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.1.3" />
|
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.1.3" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.1" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.1" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.1" />
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
|
|
||||||
public class GracePeriodConfirmedIntegrationEvent : IntegrationEvent
|
public record GracePeriodConfirmedIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int OrderId { get; }
|
public int OrderId { get; }
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace Ordering.SignalrHub.IntegrationEvents
|
namespace Ordering.SignalrHub.IntegrationEvents
|
||||||
{
|
{
|
||||||
public class OrderStatusChangedToAwaitingValidationIntegrationEvent : IntegrationEvent
|
public record OrderStatusChangedToAwaitingValidationIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int OrderId { get; }
|
public int OrderId { get; }
|
||||||
public string OrderStatus { get; }
|
public string OrderStatus { get; }
|
||||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Ordering.SignalrHub.IntegrationEvents.Events
|
namespace Ordering.SignalrHub.IntegrationEvents.Events
|
||||||
{
|
{
|
||||||
public class OrderStatusChangedToCancelledIntegrationEvent : IntegrationEvent
|
public record OrderStatusChangedToCancelledIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int OrderId { get; }
|
public int OrderId { get; }
|
||||||
public string OrderStatus { get; }
|
public string OrderStatus { get; }
|
||||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Ordering.SignalrHub.IntegrationEvents.Events
|
namespace Ordering.SignalrHub.IntegrationEvents.Events
|
||||||
{
|
{
|
||||||
public class OrderStatusChangedToPaidIntegrationEvent : IntegrationEvent
|
public record OrderStatusChangedToPaidIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int OrderId { get; }
|
public int OrderId { get; }
|
||||||
public string OrderStatus { get; }
|
public string OrderStatus { get; }
|
||||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Ordering.SignalrHub.IntegrationEvents.Events
|
namespace Ordering.SignalrHub.IntegrationEvents.Events
|
||||||
{
|
{
|
||||||
public class OrderStatusChangedToShippedIntegrationEvent : IntegrationEvent
|
public record OrderStatusChangedToShippedIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int OrderId { get; }
|
public int OrderId { get; }
|
||||||
public string OrderStatus { get; }
|
public string OrderStatus { get; }
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Ordering.SignalrHub.IntegrationEvents.Events
|
namespace Ordering.SignalrHub.IntegrationEvents.Events
|
||||||
{
|
{
|
||||||
public class OrderStatusChangedToStockConfirmedIntegrationEvent : IntegrationEvent
|
public record OrderStatusChangedToStockConfirmedIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int OrderId { get; }
|
public int OrderId { get; }
|
||||||
public string OrderStatus { get; }
|
public string OrderStatus { get; }
|
||||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Ordering.SignalrHub.IntegrationEvents.Events
|
namespace Ordering.SignalrHub.IntegrationEvents.Events
|
||||||
{
|
{
|
||||||
public class OrderStatusChangedToSubmittedIntegrationEvent : IntegrationEvent
|
public record OrderStatusChangedToSubmittedIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int OrderId { get; }
|
public int OrderId { get; }
|
||||||
public string OrderStatus { get; }
|
public string OrderStatus { get; }
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.16.0" />
|
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.16.0" />
|
||||||
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.16.0" />
|
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.16.0" />
|
||||||
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.1.3" />
|
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.1.3" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.1" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="3.0.0-preview4-19123-01" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="3.0.0-preview4-19123-01" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="3.1.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="3.1.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
|
|
||||||
public class OrderPaymentFailedIntegrationEvent : IntegrationEvent
|
public record OrderPaymentFailedIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int OrderId { get; }
|
public int OrderId { get; }
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
|
|
||||||
public class OrderPaymentSucceededIntegrationEvent : IntegrationEvent
|
public record OrderPaymentSucceededIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int OrderId { get; }
|
public int OrderId { get; }
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
|
|
||||||
public class OrderStatusChangedToStockConfirmedIntegrationEvent : IntegrationEvent
|
public record OrderStatusChangedToStockConfirmedIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int OrderId { get; }
|
public int OrderId { get; }
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
|
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
|
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
||||||
# It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles
|
# It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles
|
||||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Webhooks.API.IntegrationEvents
|
namespace Webhooks.API.IntegrationEvents
|
||||||
{
|
{
|
||||||
public class OrderStatusChangedToPaidIntegrationEvent : IntegrationEvent
|
public record OrderStatusChangedToPaidIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int OrderId { get; }
|
public int OrderId { get; }
|
||||||
public IEnumerable<OrderStockItem> OrderStockItems { get; }
|
public IEnumerable<OrderStockItem> OrderStockItems { get; }
|
||||||
@ -19,7 +19,7 @@ namespace Webhooks.API.IntegrationEvents
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class OrderStockItem
|
public record OrderStockItem
|
||||||
{
|
{
|
||||||
public int ProductId { get; }
|
public int ProductId { get; }
|
||||||
public int Units { get; }
|
public int Units { get; }
|
||||||
|
@ -1,16 +1,12 @@
|
|||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Webhooks.API.IntegrationEvents
|
namespace Webhooks.API.IntegrationEvents
|
||||||
{
|
{
|
||||||
public class OrderStatusChangedToShippedIntegrationEvent : IntegrationEvent
|
public record OrderStatusChangedToShippedIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int OrderId { get; private set; }
|
public int OrderId { get; private init; }
|
||||||
public string OrderStatus { get; private set; }
|
public string OrderStatus { get; private init; }
|
||||||
public string BuyerName { get; private set; }
|
public string BuyerName { get; private init; }
|
||||||
|
|
||||||
public OrderStatusChangedToShippedIntegrationEvent(int orderId, string orderStatus, string buyerName)
|
public OrderStatusChangedToShippedIntegrationEvent(int orderId, string orderStatus, string buyerName)
|
||||||
{
|
{
|
||||||
|
@ -1,18 +1,14 @@
|
|||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Webhooks.API.IntegrationEvents
|
namespace Webhooks.API.IntegrationEvents
|
||||||
{
|
{
|
||||||
public class ProductPriceChangedIntegrationEvent : IntegrationEvent
|
public record ProductPriceChangedIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int ProductId { get; private set; }
|
public int ProductId { get; private init; }
|
||||||
|
|
||||||
public decimal NewPrice { get; private set; }
|
public decimal NewPrice { get; private init; }
|
||||||
|
|
||||||
public decimal OldPrice { get; private set; }
|
public decimal OldPrice { get; private init; }
|
||||||
|
|
||||||
public ProductPriceChangedIntegrationEvent(int productId, decimal newPrice, decimal oldPrice)
|
public ProductPriceChangedIntegrationEvent(int productId, decimal newPrice, decimal oldPrice)
|
||||||
{
|
{
|
||||||
|
@ -7,20 +7,15 @@ using Microsoft.AspNetCore;
|
|||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Webhooks.API;
|
||||||
using Webhooks.API.Infrastructure;
|
using Webhooks.API.Infrastructure;
|
||||||
|
|
||||||
namespace Webhooks.API
|
CreateWebHostBuilder(args).Build()
|
||||||
{
|
.MigrateDbContext<WebhooksContext>((_, __) => { })
|
||||||
public class Program
|
.Run();
|
||||||
{
|
|
||||||
public static void Main(string[] args)
|
|
||||||
{
|
|
||||||
CreateWebHostBuilder(args).Build()
|
|
||||||
.MigrateDbContext<WebhooksContext>((_,__) => { })
|
|
||||||
.Run();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
|
|
||||||
|
IWebHostBuilder CreateWebHostBuilder(string[] args) =>
|
||||||
WebHost.CreateDefaultBuilder(args)
|
WebHost.CreateDefaultBuilder(args)
|
||||||
.UseStartup<Startup>()
|
.UseStartup<Startup>()
|
||||||
.ConfigureAppConfiguration((builderContext, config) =>
|
.ConfigureAppConfiguration((builderContext, config) =>
|
||||||
@ -34,5 +29,3 @@ namespace Webhooks.API
|
|||||||
builder.AddDebug();
|
builder.AddDebug();
|
||||||
builder.AddAzureWebAppDiagnostics();
|
builder.AddAzureWebAppDiagnostics();
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -174,11 +174,6 @@ namespace Webhooks.API
|
|||||||
//Configuring Connection Resiliency: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency
|
//Configuring Connection Resiliency: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency
|
||||||
sqlOptions.EnableRetryOnFailure(maxRetryCount: 15, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null);
|
sqlOptions.EnableRetryOnFailure(maxRetryCount: 15, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Changing default behavior when client evaluation occurs to throw.
|
|
||||||
// Default in EF Core would be to log a warning when client evaluation is performed.
|
|
||||||
options.ConfigureWarnings(warnings => warnings.Throw(RelationalEventId.QueryClientEvaluationWarning));
|
|
||||||
//Check Client vs. Server evaluation: https://docs.microsoft.com/en-us/ef/core/querying/client-eval
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
|
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
|
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
|
||||||
@ -11,18 +11,18 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="3.0.0" />
|
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="3.2.0" />
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="3.0.0" />
|
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="3.1.2" />
|
||||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="5.0.1" />
|
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
|
||||||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.12.0" />
|
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.16.0" />
|
||||||
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.12.0" />
|
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.16.0" />
|
||||||
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.1.1" />
|
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.1.3" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.1" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="3.0.0-alpha1-10670" PrivateAssets="All" />
|
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="3.0.0-alpha1-10670" PrivateAssets="All" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="3.1.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="5.0.1" />
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.9.5" />
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.8" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc5" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -25,6 +25,7 @@ namespace FunctionalTests.Middleware
|
|||||||
|
|
||||||
identity.AddClaim(new Claim("sub", IDENTITY_ID));
|
identity.AddClaim(new Claim("sub", IDENTITY_ID));
|
||||||
identity.AddClaim(new Claim("unique_name", IDENTITY_ID));
|
identity.AddClaim(new Claim("unique_name", IDENTITY_ID));
|
||||||
|
identity.AddClaim(new Claim(ClaimTypes.Name, IDENTITY_ID));
|
||||||
|
|
||||||
httpContext.User.AddIdentity(identity);
|
httpContext.User.AddIdentity(identity);
|
||||||
await _next.Invoke(httpContext);
|
await _next.Invoke(httpContext);
|
||||||
|
@ -20,6 +20,7 @@ namespace FunctionalTests.Services.Ordering
|
|||||||
if (Configuration["isTest"] == bool.TrueString.ToLowerInvariant())
|
if (Configuration["isTest"] == bool.TrueString.ToLowerInvariant())
|
||||||
{
|
{
|
||||||
app.UseMiddleware<AutoAuthorizeMiddleware>();
|
app.UseMiddleware<AutoAuthorizeMiddleware>();
|
||||||
|
app.UseAuthorization();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -6,5 +6,6 @@
|
|||||||
"EventBusConnection": "localhost",
|
"EventBusConnection": "localhost",
|
||||||
"CheckUpdateTime": "30000",
|
"CheckUpdateTime": "30000",
|
||||||
"GracePeriodTime": "1",
|
"GracePeriodTime": "1",
|
||||||
"SubscriptionClientName": "Ordering"
|
"SubscriptionClientName": "Ordering",
|
||||||
|
"IdentityUrlExternal": "http://localhost:5105"
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
|
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
|
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
||||||
# It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles
|
# It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles
|
||||||
|
@ -1,79 +1,77 @@
|
|||||||
using Microsoft.AspNetCore;
|
using Microsoft.AspNetCore;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.eShopOnContainers.WebMVC;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC
|
var configuration = GetConfiguration();
|
||||||
|
|
||||||
|
Log.Logger = CreateSerilogLogger(configuration);
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
public class Program
|
Log.Information("Configuring web host ({ApplicationContext})...", Program.AppName);
|
||||||
{
|
var host = BuildWebHost(configuration, args);
|
||||||
public static readonly string Namespace = typeof(Program).Namespace;
|
|
||||||
public static readonly string AppName = Namespace.Substring(Namespace.LastIndexOf('.', Namespace.LastIndexOf('.') - 1) + 1);
|
|
||||||
|
|
||||||
public static int Main(string[] args)
|
Log.Information("Starting web host ({ApplicationContext})...", Program.AppName);
|
||||||
{
|
host.Run();
|
||||||
var configuration = GetConfiguration();
|
|
||||||
|
|
||||||
Log.Logger = CreateSerilogLogger(configuration);
|
return 0;
|
||||||
|
}
|
||||||
try
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Log.Information("Configuring web host ({ApplicationContext})...", AppName);
|
Log.Fatal(ex, "Program terminated unexpectedly ({ApplicationContext})!", Program.AppName);
|
||||||
var host = BuildWebHost(configuration, args);
|
return 1;
|
||||||
|
}
|
||||||
Log.Information("Starting web host ({ApplicationContext})...", AppName);
|
finally
|
||||||
host.Run();
|
{
|
||||||
|
Log.CloseAndFlush();
|
||||||
return 0;
|
}
|
||||||
}
|
|
||||||
catch (Exception ex)
|
IWebHost BuildWebHost(IConfiguration configuration, string[] args) =>
|
||||||
{
|
WebHost.CreateDefaultBuilder(args)
|
||||||
Log.Fatal(ex, "Program terminated unexpectedly ({ApplicationContext})!", AppName);
|
.CaptureStartupErrors(false)
|
||||||
return 1;
|
.ConfigureAppConfiguration(x => x.AddConfiguration(configuration))
|
||||||
}
|
.UseStartup<Startup>()
|
||||||
finally
|
.UseSerilog()
|
||||||
{
|
.Build();
|
||||||
Log.CloseAndFlush();
|
|
||||||
}
|
Serilog.ILogger CreateSerilogLogger(IConfiguration configuration)
|
||||||
}
|
{
|
||||||
|
var seqServerUrl = configuration["Serilog:SeqServerUrl"];
|
||||||
private static IWebHost BuildWebHost(IConfiguration configuration, string[] args) =>
|
var logstashUrl = configuration["Serilog:LogstashgUrl"];
|
||||||
WebHost.CreateDefaultBuilder(args)
|
var cfg = new LoggerConfiguration()
|
||||||
.CaptureStartupErrors(false)
|
.ReadFrom.Configuration(configuration)
|
||||||
.ConfigureAppConfiguration(x => x.AddConfiguration(configuration))
|
.Enrich.WithProperty("ApplicationContext", Program.AppName)
|
||||||
.UseStartup<Startup>()
|
.Enrich.FromLogContext()
|
||||||
.UseSerilog()
|
.WriteTo.Console();
|
||||||
.Build();
|
if (!string.IsNullOrWhiteSpace(seqServerUrl))
|
||||||
|
{
|
||||||
private static Serilog.ILogger CreateSerilogLogger(IConfiguration configuration)
|
cfg.WriteTo.Seq(seqServerUrl);
|
||||||
{
|
}
|
||||||
var seqServerUrl = configuration["Serilog:SeqServerUrl"];
|
if (!string.IsNullOrWhiteSpace(logstashUrl))
|
||||||
var logstashUrl = configuration["Serilog:LogstashgUrl"];
|
{
|
||||||
var cfg = new LoggerConfiguration()
|
cfg.WriteTo.Http(logstashUrl);
|
||||||
.ReadFrom.Configuration(configuration)
|
}
|
||||||
.Enrich.WithProperty("ApplicationContext", AppName)
|
return cfg.CreateLogger();
|
||||||
.Enrich.FromLogContext()
|
}
|
||||||
.WriteTo.Console();
|
|
||||||
if (!string.IsNullOrWhiteSpace(seqServerUrl)) {
|
IConfiguration GetConfiguration()
|
||||||
cfg.WriteTo.Seq(seqServerUrl);
|
{
|
||||||
}
|
var builder = new ConfigurationBuilder()
|
||||||
if (!string.IsNullOrWhiteSpace(logstashUrl)) {
|
.SetBasePath(Directory.GetCurrentDirectory())
|
||||||
cfg.WriteTo.Http(logstashUrl);
|
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||||||
}
|
.AddEnvironmentVariables();
|
||||||
return cfg.CreateLogger();
|
|
||||||
}
|
return builder.Build();
|
||||||
|
}
|
||||||
private static IConfiguration GetConfiguration()
|
|
||||||
{
|
|
||||||
var builder = new ConfigurationBuilder()
|
public class Program
|
||||||
.SetBasePath(Directory.GetCurrentDirectory())
|
{
|
||||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
private static readonly string _namespace = typeof(Startup).Namespace;
|
||||||
.AddEnvironmentVariables();
|
public static readonly string AppName = _namespace.Substring(_namespace.LastIndexOf('.', _namespace.LastIndexOf('.') - 1) + 1);
|
||||||
|
|
||||||
return builder.Build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -3,35 +3,35 @@ using System.ComponentModel.DataAnnotations;
|
|||||||
|
|
||||||
namespace WebMVC.Services.ModelDTOs
|
namespace WebMVC.Services.ModelDTOs
|
||||||
{
|
{
|
||||||
public class BasketDTO
|
public record BasketDTO
|
||||||
{
|
{
|
||||||
[Required]
|
[Required]
|
||||||
public string City { get; set; }
|
public string City { get; init; }
|
||||||
[Required]
|
[Required]
|
||||||
public string Street { get; set; }
|
public string Street { get; init; }
|
||||||
[Required]
|
[Required]
|
||||||
public string State { get; set; }
|
public string State { get; init; }
|
||||||
[Required]
|
[Required]
|
||||||
public string Country { get; set; }
|
public string Country { get; init; }
|
||||||
|
|
||||||
public string ZipCode { get; set; }
|
public string ZipCode { get; init; }
|
||||||
[Required]
|
[Required]
|
||||||
public string CardNumber { get; set; }
|
public string CardNumber { get; init; }
|
||||||
[Required]
|
[Required]
|
||||||
public string CardHolderName { get; set; }
|
public string CardHolderName { get; init; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public DateTime CardExpiration { get; set; }
|
public DateTime CardExpiration { get; init; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public string CardSecurityNumber { get; set; }
|
public string CardSecurityNumber { get; init; }
|
||||||
|
|
||||||
public int CardTypeId { get; set; }
|
public int CardTypeId { get; init; }
|
||||||
|
|
||||||
public string Buyer { get; set; }
|
public string Buyer { get; init; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public Guid RequestId { get; set; }
|
public Guid RequestId { get; init; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
namespace WebMVC.Services.ModelDTOs
|
namespace WebMVC.Services.ModelDTOs
|
||||||
{
|
{
|
||||||
public class LocationDTO
|
public record LocationDTO
|
||||||
{
|
{
|
||||||
public double Longitude { get; set; }
|
public double Longitude { get; init; }
|
||||||
public double Latitude { get; set; }
|
public double Latitude { get; init; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
namespace WebMVC.Services.ModelDTOs
|
namespace WebMVC.Services.ModelDTOs
|
||||||
{
|
{
|
||||||
public class OrderDTO
|
public record OrderDTO
|
||||||
{
|
{
|
||||||
[Required]
|
[Required]
|
||||||
public string OrderNumber { get; set; }
|
public string OrderNumber { get; init; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,9 +1,9 @@
|
|||||||
namespace WebMVC.Services.ModelDTOs
|
namespace WebMVC.Services.ModelDTOs
|
||||||
{
|
{
|
||||||
public class OrderProcessAction
|
public record OrderProcessAction
|
||||||
{
|
{
|
||||||
public string Code { get; private set; }
|
public string Code { get; }
|
||||||
public string Name { get; private set; }
|
public string Name { get; }
|
||||||
|
|
||||||
public static OrderProcessAction Ship = new OrderProcessAction(nameof(Ship).ToLowerInvariant(), "Ship");
|
public static OrderProcessAction Ship = new OrderProcessAction(nameof(Ship).ToLowerInvariant(), "Ship");
|
||||||
|
|
||||||
|
@ -7,19 +7,16 @@ using Microsoft.AspNetCore.DataProtection;
|
|||||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.eShopOnContainers.WebMVC.Services;
|
using Microsoft.eShopOnContainers.WebMVC.Services;
|
||||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Microsoft.IdentityModel.Logging;
|
using Microsoft.IdentityModel.Logging;
|
||||||
using StackExchange.Redis;
|
using StackExchange.Redis;
|
||||||
using System;
|
using System;
|
||||||
using System.IdentityModel.Tokens.Jwt;
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
using System.Net.Http;
|
|
||||||
using WebMVC.Infrastructure;
|
using WebMVC.Infrastructure;
|
||||||
using WebMVC.Infrastructure.Middlewares;
|
using WebMVC.Infrastructure.Middlewares;
|
||||||
using WebMVC.Services;
|
using WebMVC.Services;
|
||||||
|
@ -1,18 +1,17 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
||||||
{
|
{
|
||||||
public class Basket
|
public record Basket
|
||||||
{
|
{
|
||||||
// Use property initializer syntax.
|
// Use property initializer syntax.
|
||||||
// While this is often more useful for read only
|
// While this is often more useful for read only
|
||||||
// auto implemented properties, it can simplify logic
|
// auto implemented properties, it can simplify logic
|
||||||
// for read/write properties.
|
// for read/write properties.
|
||||||
public List<BasketItem> Items { get; set; } = new List<BasketItem>();
|
public List<BasketItem> Items { get; init; } = new List<BasketItem>();
|
||||||
public string BuyerId { get; set; }
|
public string BuyerId { get; init; }
|
||||||
|
|
||||||
public decimal Total()
|
public decimal Total()
|
||||||
{
|
{
|
||||||
|
@ -1,18 +1,13 @@
|
|||||||
using System;
|
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
|
||||||
{
|
{
|
||||||
public class BasketItem
|
public record BasketItem
|
||||||
{
|
{
|
||||||
public string Id { get; set; }
|
public string Id { get; init; }
|
||||||
public string ProductId { get; set; }
|
public string ProductId { get; init; }
|
||||||
public string ProductName { get; set; }
|
public string ProductName { get; init; }
|
||||||
public decimal UnitPrice { get; set; }
|
public decimal UnitPrice { get; init; }
|
||||||
public decimal OldUnitPrice { get; set; }
|
public decimal OldUnitPrice { get; init; }
|
||||||
public int Quantity { get; set; }
|
public int Quantity { get; init; }
|
||||||
public string PictureUrl { get; set; }
|
public string PictureUrl { get; init; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
using System.Collections.Generic;
|
||||||
{
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
public class Campaign
|
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
||||||
|
{
|
||||||
|
public record Campaign
|
||||||
{
|
{
|
||||||
public int PageIndex { get; set; }
|
public int PageIndex { get; init; }
|
||||||
public int PageSize { get; set; }
|
public int PageSize { get; init; }
|
||||||
public int Count { get; set; }
|
public int Count { get; init; }
|
||||||
public List<CampaignItem> Data { get; set; }
|
public List<CampaignItem> Data { get; init; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,20 +1,20 @@
|
|||||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
using System;
|
||||||
|
|
||||||
|
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
||||||
{
|
{
|
||||||
using System;
|
public record CampaignItem
|
||||||
|
|
||||||
public class CampaignItem
|
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; init; }
|
||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; init; }
|
||||||
|
|
||||||
public string Description { get; set; }
|
public string Description { get; init; }
|
||||||
|
|
||||||
public DateTime From { get; set; }
|
public DateTime From { get; init; }
|
||||||
|
|
||||||
public DateTime To { get; set; }
|
public DateTime To { get; init; }
|
||||||
|
|
||||||
public string PictureUri { get; set; }
|
public string PictureUri { get; init; }
|
||||||
public string DetailsUri { get; set; }
|
public string DetailsUri { get; init; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,10 +1,4 @@
|
|||||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels.CartViewModels
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels.CartViewModels
|
|
||||||
{
|
{
|
||||||
public class CartComponentViewModel
|
public class CartComponentViewModel
|
||||||
{
|
{
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
||||||
{
|
{
|
||||||
public class Catalog
|
public record Catalog
|
||||||
{
|
{
|
||||||
public int PageIndex { get; set; }
|
public int PageIndex { get; init; }
|
||||||
public int PageSize { get; set; }
|
public int PageSize { get; init; }
|
||||||
public int Count { get; set; }
|
public int Count { get; init; }
|
||||||
public List<CatalogItem> Data { get; set; }
|
public List<CatalogItem> Data { get; init; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,15 @@
|
|||||||
using System;
|
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
|
||||||
{
|
{
|
||||||
public class CatalogItem
|
public record CatalogItem
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; init; }
|
||||||
public string Name { get; set; }
|
public string Name { get; init; }
|
||||||
public string Description { get; set; }
|
public string Description { get; init; }
|
||||||
public decimal Price { get; set; }
|
public decimal Price { get; init; }
|
||||||
public string PictureUri { get; set; }
|
public string PictureUri { get; init; }
|
||||||
public int CatalogBrandId { get; set; }
|
public int CatalogBrandId { get; init; }
|
||||||
public string CatalogBrand { get; set; }
|
public string CatalogBrand { get; init; }
|
||||||
public int CatalogTypeId { get; set; }
|
public int CatalogTypeId { get; init; }
|
||||||
public string CatalogType { get; set; }
|
public string CatalogType { get; init; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,9 +1,6 @@
|
|||||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels.Pagination;
|
using Microsoft.eShopOnContainers.WebMVC.ViewModels.Pagination;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels.CatalogViewModels
|
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels.CatalogViewModels
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
using System;
|
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
|
||||||
{
|
{
|
||||||
public class Header
|
public record Header
|
||||||
{
|
{
|
||||||
public string Controller { get; set; }
|
public string Controller { get; init; }
|
||||||
public string Text { get; set; }
|
public string Text { get; init; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,22 +1,17 @@
|
|||||||
using System;
|
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
|
||||||
{
|
{
|
||||||
public class OrderItem
|
public record OrderItem
|
||||||
{
|
{
|
||||||
public int ProductId { get; set; }
|
public int ProductId { get; init; }
|
||||||
|
|
||||||
public string ProductName { get; set; }
|
public string ProductName { get; init; }
|
||||||
|
|
||||||
public decimal UnitPrice { get; set; }
|
public decimal UnitPrice { get; init; }
|
||||||
|
|
||||||
public decimal Discount { get; set; }
|
public decimal Discount { get; init; }
|
||||||
|
|
||||||
public int Units { get; set; }
|
public int Units { get; init; }
|
||||||
|
|
||||||
public string PictureUrl { get; set; }
|
public string PictureUrl { get; init; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
using System;
|
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels.Pagination
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels.Pagination
|
|
||||||
{
|
{
|
||||||
public class PaginationInfo
|
public class PaginationInfo
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<UserSecretsId>aspnet-Microsoft.eShopOnContainers-946ae052-8305-4a99-965b-ec8636ddbae3</UserSecretsId>
|
<UserSecretsId>aspnet-Microsoft.eShopOnContainers-946ae052-8305-4a99-965b-ec8636ddbae3</UserSecretsId>
|
||||||
<DockerComposeProjectPath>..\..\..\docker-compose.dcproj</DockerComposeProjectPath>
|
<DockerComposeProjectPath>..\..\..\docker-compose.dcproj</DockerComposeProjectPath>
|
||||||
<TypeScriptToolsVersion>3.0</TypeScriptToolsVersion>
|
<TypeScriptToolsVersion>3.0</TypeScriptToolsVersion>
|
||||||
@ -23,25 +23,25 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.3" />
|
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.3" />
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="3.0.0" />
|
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="3.1.2" />
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="3.0.0" />
|
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="3.1.2" />
|
||||||
<PackageReference Include="BuildBundlerMinifier" Version="3.2.435" />
|
<PackageReference Include="BuildBundlerMinifier" Version="3.2.449" />
|
||||||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.12.0" />
|
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.16.0" />
|
||||||
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.12.0" />
|
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.16.0" />
|
||||||
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.1.1" />
|
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.1.3" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.1" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="3.1.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="3.1.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.DataProtection.Redis" Version="2.2.0-preview3-35458" />
|
<PackageReference Include="Microsoft.AspNetCore.DataProtection.Redis" Version="2.2.0-preview3-35458" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
|
||||||
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="16.4.0" />
|
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="16.8.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="3.1.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="5.0.1" />
|
||||||
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="2.0.96" />
|
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="2.1.113" />
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="3.2.0" />
|
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
|
||||||
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.3" />
|
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.3" />
|
||||||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.1-dev-00216" />
|
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.1-dev-00216" />
|
||||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.0-dev-00834" />
|
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.0-dev-00834" />
|
||||||
<PackageReference Include="Serilog.Sinks.Http" Version="5.2.0" />
|
<PackageReference Include="Serilog.Sinks.Http" Version="7.2.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.Seq" Version="4.1.0-dev-00166" />
|
<PackageReference Include="Serilog.Sinks.Seq" Version="4.1.0-dev-00166" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
ARG NODE_IMAGE=node:12.0
|
ARG NODE_IMAGE=node:12.0
|
||||||
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
|
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ COPY Web/WebSPA/package-lock.json .
|
|||||||
COPY Web/WebSPA .
|
COPY Web/WebSPA .
|
||||||
RUN npm i npm@latest -g && npm update && npm install && npm run build:prod
|
RUN npm i npm@latest -g && npm update && npm install && npm run build:prod
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
|
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
||||||
# It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles
|
# It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles
|
||||||
|
@ -4,38 +4,30 @@ using System.IO;
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
using eShopConContainers.WebSPA;
|
||||||
|
|
||||||
namespace eShopConContainers.WebSPA
|
BuildWebHost(args).Run();
|
||||||
{
|
|
||||||
public class Program
|
IWebHost BuildWebHost(string[] args) =>
|
||||||
{
|
WebHost.CreateDefaultBuilder(args)
|
||||||
public static void Main(string[] args)
|
.UseStartup<Startup>()
|
||||||
|
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||||
|
.ConfigureAppConfiguration((builderContext, config) =>
|
||||||
{
|
{
|
||||||
BuildWebHost(args).Run();
|
config.AddEnvironmentVariables();
|
||||||
}
|
})
|
||||||
|
.ConfigureLogging((hostingContext, builder) =>
|
||||||
public static IWebHost BuildWebHost(string[] args) =>
|
{
|
||||||
WebHost.CreateDefaultBuilder(args)
|
builder.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
|
||||||
.UseStartup<Startup>()
|
builder.AddConsole();
|
||||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
builder.AddDebug();
|
||||||
.ConfigureAppConfiguration((builderContext, config) =>
|
builder.AddAzureWebAppDiagnostics();
|
||||||
{
|
})
|
||||||
config.AddEnvironmentVariables();
|
.UseSerilog((builderContext, config) =>
|
||||||
})
|
{
|
||||||
.ConfigureLogging((hostingContext, builder) =>
|
config
|
||||||
{
|
.MinimumLevel.Information()
|
||||||
builder.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
|
.Enrich.FromLogContext()
|
||||||
builder.AddConsole();
|
.WriteTo.Console();
|
||||||
builder.AddDebug();
|
})
|
||||||
builder.AddAzureWebAppDiagnostics();
|
.Build();
|
||||||
})
|
|
||||||
.UseSerilog((builderContext, config) =>
|
|
||||||
{
|
|
||||||
config
|
|
||||||
.MinimumLevel.Information()
|
|
||||||
.Enrich.FromLogContext()
|
|
||||||
.WriteTo.Console();
|
|
||||||
})
|
|
||||||
.Build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<UserSecretsId>aspnetcorespa-c23d27a4-eb88-4b18-9b77-2a93f3b15119</UserSecretsId>
|
<UserSecretsId>aspnetcorespa-c23d27a4-eb88-4b18-9b77-2a93f3b15119</UserSecretsId>
|
||||||
<DockerComposeProjectPath>..\..\..\docker-compose.dcproj</DockerComposeProjectPath>
|
<DockerComposeProjectPath>..\..\..\docker-compose.dcproj</DockerComposeProjectPath>
|
||||||
<TypeScriptCompileOnSaveEnabled>false</TypeScriptCompileOnSaveEnabled>
|
<TypeScriptCompileOnSaveEnabled>false</TypeScriptCompileOnSaveEnabled>
|
||||||
@ -87,16 +87,16 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="3.0.0" />
|
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="3.1.2" />
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="3.0.0" />
|
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="3.1.2" />
|
||||||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.12.0" />
|
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.16.0" />
|
||||||
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.12.0" />
|
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.16.0" />
|
||||||
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.1.1" />
|
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.1.3" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.DataProtection.Redis" Version="2.2.0-preview3-35458" />
|
<PackageReference Include="Microsoft.AspNetCore.DataProtection.Redis" Version="2.2.0-preview3-35458" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="3.1.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="5.0.1" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="3.2.0" />
|
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.0-dev-00834" />
|
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.0-dev-00834" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
|
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
|
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
||||||
# It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles
|
# It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles
|
||||||
|
@ -7,119 +7,114 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using WebStatus;
|
||||||
|
|
||||||
namespace WebStatus
|
var configuration = GetConfiguration();
|
||||||
|
|
||||||
|
Log.Logger = CreateSerilogLogger(configuration);
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
public class Program
|
Log.Information("Configuring web host ({ApplicationContext})...", Program.AppName);
|
||||||
|
var host = BuildWebHost(configuration, args);
|
||||||
|
|
||||||
|
LogPackagesVersionInfo();
|
||||||
|
|
||||||
|
Log.Information("Starting web host ({ApplicationContext})...", Program.AppName);
|
||||||
|
host.Run();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Fatal(ex, "Program terminated unexpectedly ({ApplicationContext})!", Program.AppName);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Log.CloseAndFlush();
|
||||||
|
}
|
||||||
|
|
||||||
|
IWebHost BuildWebHost(IConfiguration configuration, string[] args) =>
|
||||||
|
WebHost.CreateDefaultBuilder(args)
|
||||||
|
.CaptureStartupErrors(false)
|
||||||
|
.ConfigureAppConfiguration(x => x.AddConfiguration(configuration))
|
||||||
|
.UseStartup<Startup>()
|
||||||
|
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||||
|
.UseSerilog()
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
Serilog.ILogger CreateSerilogLogger(IConfiguration configuration)
|
||||||
|
{
|
||||||
|
var seqServerUrl = configuration["Serilog:SeqServerUrl"];
|
||||||
|
var logstashUrl = configuration["Serilog:LogstashgUrl"];
|
||||||
|
return new LoggerConfiguration()
|
||||||
|
.MinimumLevel.Verbose()
|
||||||
|
.Enrich.WithProperty("ApplicationContext", Program.AppName)
|
||||||
|
.Enrich.FromLogContext()
|
||||||
|
.WriteTo.Console()
|
||||||
|
.WriteTo.Seq(string.IsNullOrWhiteSpace(seqServerUrl) ? "http://seq" : seqServerUrl)
|
||||||
|
.WriteTo.Http(string.IsNullOrWhiteSpace(logstashUrl) ? "http://logstash:8080" : logstashUrl)
|
||||||
|
.ReadFrom.Configuration(configuration)
|
||||||
|
.CreateLogger();
|
||||||
|
}
|
||||||
|
|
||||||
|
IConfiguration GetConfiguration()
|
||||||
|
{
|
||||||
|
var builder = new ConfigurationBuilder()
|
||||||
|
.SetBasePath(Directory.GetCurrentDirectory())
|
||||||
|
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||||||
|
.AddEnvironmentVariables();
|
||||||
|
|
||||||
|
var config = builder.Build();
|
||||||
|
|
||||||
|
if (config.GetValue<bool>("UseVault", false))
|
||||||
{
|
{
|
||||||
public static readonly string Namespace = typeof(Program).Namespace;
|
builder.AddAzureKeyVault(
|
||||||
public static readonly string AppName = Namespace;
|
$"https://{config["Vault:Name"]}.vault.azure.net/",
|
||||||
|
config["Vault:ClientId"],
|
||||||
|
config["Vault:ClientSecret"]);
|
||||||
|
}
|
||||||
|
|
||||||
public static int Main(string[] args)
|
return builder.Build();
|
||||||
{
|
}
|
||||||
var configuration = GetConfiguration();
|
|
||||||
|
|
||||||
Log.Logger = CreateSerilogLogger(configuration);
|
string GetVersion(Assembly assembly)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Log.Information("Configuring web host ({ApplicationContext})...", AppName);
|
return $"{assembly.GetCustomAttribute<AssemblyFileVersionAttribute>()?.Version} ({assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion.Split()[0]})";
|
||||||
var host = BuildWebHost(configuration, args);
|
}
|
||||||
|
catch
|
||||||
LogPackagesVersionInfo();
|
{
|
||||||
|
return string.Empty;
|
||||||
Log.Information("Starting web host ({ApplicationContext})...", AppName);
|
|
||||||
host.Run();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Log.Fatal(ex, "Program terminated unexpectedly ({ApplicationContext})!", AppName);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
Log.CloseAndFlush();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static IWebHost BuildWebHost(IConfiguration configuration, string[] args) =>
|
|
||||||
WebHost.CreateDefaultBuilder(args)
|
|
||||||
.CaptureStartupErrors(false)
|
|
||||||
.ConfigureAppConfiguration(x => x.AddConfiguration(configuration))
|
|
||||||
.UseStartup<Startup>()
|
|
||||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
|
||||||
.UseSerilog()
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
private static Serilog.ILogger CreateSerilogLogger(IConfiguration configuration)
|
|
||||||
{
|
|
||||||
var seqServerUrl = configuration["Serilog:SeqServerUrl"];
|
|
||||||
var logstashUrl = configuration["Serilog:LogstashgUrl"];
|
|
||||||
return new LoggerConfiguration()
|
|
||||||
.MinimumLevel.Verbose()
|
|
||||||
.Enrich.WithProperty("ApplicationContext", AppName)
|
|
||||||
.Enrich.FromLogContext()
|
|
||||||
.WriteTo.Console()
|
|
||||||
.WriteTo.Seq(string.IsNullOrWhiteSpace(seqServerUrl) ? "http://seq" : seqServerUrl)
|
|
||||||
.WriteTo.Http(string.IsNullOrWhiteSpace(logstashUrl) ? "http://logstash:8080" : logstashUrl)
|
|
||||||
.ReadFrom.Configuration(configuration)
|
|
||||||
.CreateLogger();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static IConfiguration GetConfiguration()
|
|
||||||
{
|
|
||||||
var builder = new ConfigurationBuilder()
|
|
||||||
.SetBasePath(Directory.GetCurrentDirectory())
|
|
||||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
|
||||||
.AddEnvironmentVariables();
|
|
||||||
|
|
||||||
var config = builder.Build();
|
|
||||||
|
|
||||||
if (config.GetValue<bool>("UseVault", false))
|
|
||||||
{
|
|
||||||
builder.AddAzureKeyVault(
|
|
||||||
$"https://{config["Vault:Name"]}.vault.azure.net/",
|
|
||||||
config["Vault:ClientId"],
|
|
||||||
config["Vault:ClientSecret"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return builder.Build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string GetVersion(Assembly assembly)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return $"{assembly.GetCustomAttribute<AssemblyFileVersionAttribute>()?.Version} ({assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion.Split()[0]})";
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void LogPackagesVersionInfo()
|
|
||||||
{
|
|
||||||
var assemblies = new List<Assembly>();
|
|
||||||
|
|
||||||
foreach (var dependencyName in typeof(Program).Assembly.GetReferencedAssemblies())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Try to load the referenced assembly...
|
|
||||||
assemblies.Add(Assembly.Load(dependencyName));
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
// Failed to load assembly. Skip it.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var versionList = assemblies.Select(a => $"-{a.GetName().Name} - {GetVersion(a)}").OrderBy(value => value);
|
|
||||||
|
|
||||||
Log.Logger.ForContext("PackageVersions", string.Join("\n", versionList)).Information("Package versions ({ApplicationContext})", AppName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LogPackagesVersionInfo()
|
||||||
|
{
|
||||||
|
var assemblies = new List<Assembly>();
|
||||||
|
|
||||||
|
foreach (var dependencyName in typeof(Program).Assembly.GetReferencedAssemblies())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Try to load the referenced assembly...
|
||||||
|
assemblies.Add(Assembly.Load(dependencyName));
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// Failed to load assembly. Skip it.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var versionList = assemblies.Select(a => $"-{a.GetName().Name} - {GetVersion(a)}").OrderBy(value => value);
|
||||||
|
|
||||||
|
Log.Logger.ForContext("PackageVersions", string.Join("\n", versionList)).Information("Package versions ({ApplicationContext})", Program.AppName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
private static readonly string _namespace = typeof(Startup).Namespace;
|
||||||
|
public static readonly string AppName = _namespace;
|
||||||
|
}
|
@ -30,7 +30,10 @@ namespace WebStatus
|
|||||||
services.AddHealthChecks()
|
services.AddHealthChecks()
|
||||||
.AddCheck("self", () => HealthCheckResult.Healthy());
|
.AddCheck("self", () => HealthCheckResult.Healthy());
|
||||||
|
|
||||||
services.AddHealthChecksUI();
|
services
|
||||||
|
.AddHealthChecksUI()
|
||||||
|
.AddInMemoryStorage();
|
||||||
|
|
||||||
services.AddMvc()
|
services.AddMvc()
|
||||||
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
|
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
|
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
|
||||||
<DockerComposeProjectPath>..\..\..\docker-compose.dcproj</DockerComposeProjectPath>
|
<DockerComposeProjectPath>..\..\..\docker-compose.dcproj</DockerComposeProjectPath>
|
||||||
<IsTransformWebConfigDisabled>true</IsTransformWebConfigDisabled>
|
<IsTransformWebConfigDisabled>true</IsTransformWebConfigDisabled>
|
||||||
@ -8,21 +8,22 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="3.0.0" />
|
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="3.1.2" />
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.UI" Version="3.0.6" />
|
<PackageReference Include="AspNetCore.HealthChecks.UI" Version="3.1.3" />
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="3.0.0" />
|
<PackageReference Include="AspNetCore.HealthChecks.UI.InMemory.Storage" Version="3.1.2" />
|
||||||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.12.0" />
|
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="3.1.2" />
|
||||||
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.12.0" />
|
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.16.0" />
|
||||||
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.1.1" />
|
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.16.0" />
|
||||||
|
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.1.3" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="3.1.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="3.1.10" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="3.1.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="5.0.1" />
|
||||||
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="2.0.96" />
|
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="2.1.113" />
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="3.2.0" />
|
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
|
||||||
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.3" />
|
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.3" />
|
||||||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.1-dev-00216" />
|
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.1-dev-00216" />
|
||||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.0-dev-00834" />
|
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.0-dev-00834" />
|
||||||
<PackageReference Include="Serilog.Sinks.Http" Version="5.2.0" />
|
<PackageReference Include="Serilog.Sinks.Http" Version="7.2.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.Seq" Version="4.1.0-dev-00166" />
|
<PackageReference Include="Serilog.Sinks.Seq" Version="4.1.0-dev-00166" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
|
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
EXPOSE 443
|
EXPOSE 443
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
|
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
||||||
# It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles
|
# It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles
|
||||||
|
@ -1,24 +1,10 @@
|
|||||||
using System;
|
using Microsoft.AspNetCore;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNetCore;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.Configuration;
|
using WebhookClient;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace WebhookClient
|
CreateWebHostBuilder(args).Build().Run();
|
||||||
{
|
|
||||||
public class Program
|
|
||||||
{
|
|
||||||
public static void Main(string[] args)
|
|
||||||
{
|
|
||||||
CreateWebHostBuilder(args).Build().Run();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
|
|
||||||
WebHost.CreateDefaultBuilder(args)
|
IWebHostBuilder CreateWebHostBuilder(string[] args) =>
|
||||||
.UseStartup<Startup>();
|
WebHost.CreateDefaultBuilder(args)
|
||||||
}
|
.UseStartup<Startup>();
|
||||||
}
|
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using WebhookClient.Models;
|
using WebhookClient.Models;
|
||||||
|
|
||||||
|
@ -61,7 +61,6 @@ namespace WebhookClient
|
|||||||
app.UseExceptionHandler("/Error");
|
app.UseExceptionHandler("/Error");
|
||||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||||
}
|
}
|
||||||
app.UseAuthentication();
|
|
||||||
app.Map("/check", capp =>
|
app.Map("/check", capp =>
|
||||||
{
|
{
|
||||||
capp.Run(async (context) =>
|
capp.Run(async (context) =>
|
||||||
@ -92,12 +91,20 @@ namespace WebhookClient
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Fix samesite issue when running eShop from docker-compose locally as by default http protocol is being used
|
||||||
|
// Refer to https://github.com/dotnet-architecture/eShopOnContainers/issues/1391
|
||||||
|
app.UseCookiePolicy(new CookiePolicyOptions { MinimumSameSitePolicy = SameSiteMode.Lax });
|
||||||
|
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
app.UseSession();
|
app.UseSession();
|
||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
|
app.UseAuthentication();
|
||||||
|
app.UseAuthorization();
|
||||||
app.UseEndpoints(endpoints =>
|
app.UseEndpoints(endpoints =>
|
||||||
{
|
{
|
||||||
endpoints.MapDefaultControllerRoute();
|
endpoints.MapDefaultControllerRoute();
|
||||||
|
endpoints.MapRazorPages();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
|
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
<UserSecretsId>36215d41-f31a-4aa6-9929-bd67d650e7b5</UserSecretsId>
|
<UserSecretsId>36215d41-f31a-4aa6-9929-bd67d650e7b5</UserSecretsId>
|
||||||
@ -14,8 +14,8 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
|
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="3.1.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="3.1.0" />
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.9.5" />
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.8" />
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.0" />
|
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user