diff --git a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/GrpcCallerService.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/GrpcCallerService.cs deleted file mode 100644 index 55f3df3ee..000000000 --- a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/GrpcCallerService.cs +++ /dev/null @@ -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 CallService(string urlGrpc, Func> 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 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); - } - } - } -} diff --git a/src/ApiGateways/Web.Bff.Shopping/aggregator/Services/GrpcCallerService.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Services/GrpcCallerService.cs deleted file mode 100644 index 2039c7c4f..000000000 --- a/src/ApiGateways/Web.Bff.Shopping/aggregator/Services/GrpcCallerService.cs +++ /dev/null @@ -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 CallService(string urlGrpc, Func> 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 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); - } - } - } -} diff --git a/src/BuildingBlocks/Devspaces.Support/Devspaces.Support.csproj b/src/BuildingBlocks/Devspaces.Support/Devspaces.Support.csproj index ca139c382..2ef353268 100644 --- a/src/BuildingBlocks/Devspaces.Support/Devspaces.Support.csproj +++ b/src/BuildingBlocks/Devspaces.Support/Devspaces.Support.csproj @@ -1,11 +1,11 @@  - netstandard2.0 + net5.0 - - + + diff --git a/src/BuildingBlocks/EventBus/EventBus/EventBus.csproj b/src/BuildingBlocks/EventBus/EventBus/EventBus.csproj index 69d2c0c05..8db6db3b5 100644 --- a/src/BuildingBlocks/EventBus/EventBus/EventBus.csproj +++ b/src/BuildingBlocks/EventBus/EventBus/EventBus.csproj @@ -1,7 +1,7 @@  - netstandard2.1 + net5.0 Microsoft.eShopOnContainers.BuildingBlocks.EventBus diff --git a/src/BuildingBlocks/EventBus/EventBus/Events/IntegrationEvent.cs b/src/BuildingBlocks/EventBus/EventBus/Events/IntegrationEvent.cs index ef09911fe..3fc04c1b0 100644 --- a/src/BuildingBlocks/EventBus/EventBus/Events/IntegrationEvent.cs +++ b/src/BuildingBlocks/EventBus/EventBus/Events/IntegrationEvent.cs @@ -3,7 +3,7 @@ using Newtonsoft.Json; namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events { - public class IntegrationEvent + public record IntegrationEvent { public IntegrationEvent() { @@ -19,9 +19,9 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events } [JsonProperty] - public Guid Id { get; private set; } + public Guid Id { get; private init; } [JsonProperty] - public DateTime CreationDate { get; private set; } + public DateTime CreationDate { get; private init; } } } diff --git a/src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.cs b/src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.cs index 6ee3032a8..50bd97bc9 100644 --- a/src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.cs +++ b/src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.cs @@ -203,7 +203,7 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ private async Task Consumer_Received(object sender, BasicDeliverEventArgs eventArgs) { var eventName = eventArgs.RoutingKey; - var message = Encoding.UTF8.GetString(eventArgs.Body); + var message = Encoding.UTF8.GetString(eventArgs.Body.Span); try { diff --git a/src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj b/src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj index 00b95b211..a55f434d7 100644 --- a/src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj +++ b/src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj @@ -1,17 +1,17 @@  - netstandard2.1 + net5.0 Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ - + - + - - + + diff --git a/src/BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj b/src/BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj index 8435246a3..7bf222a59 100644 --- a/src/BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj +++ b/src/BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj @@ -1,15 +1,15 @@  - netstandard2.1 + net5.0 Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus - - + + - + diff --git a/src/BuildingBlocks/EventBus/IntegrationEventLogEF/IntegrationEventLogEF.csproj b/src/BuildingBlocks/EventBus/IntegrationEventLogEF/IntegrationEventLogEF.csproj index bfc322c34..70d25579d 100644 --- a/src/BuildingBlocks/EventBus/IntegrationEventLogEF/IntegrationEventLogEF.csproj +++ b/src/BuildingBlocks/EventBus/IntegrationEventLogEF/IntegrationEventLogEF.csproj @@ -1,18 +1,18 @@  - netstandard2.1 + net5.0 Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + diff --git a/src/BuildingBlocks/WebHostCustomization/WebHost.Customization/WebHost.Customization.csproj b/src/BuildingBlocks/WebHostCustomization/WebHost.Customization/WebHost.Customization.csproj index a6ccbe05e..b7557bd96 100644 --- a/src/BuildingBlocks/WebHostCustomization/WebHost.Customization/WebHost.Customization.csproj +++ b/src/BuildingBlocks/WebHostCustomization/WebHost.Customization/WebHost.Customization.csproj @@ -1,22 +1,23 @@  - netcoreapp3.1 + net5.0 false - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - + + + + + + + diff --git a/src/Services/Basket/Basket.API/Basket.API.csproj b/src/Services/Basket/Basket.API/Basket.API.csproj index 4921041f2..68cf191f9 100644 --- a/src/Services/Basket/Basket.API/Basket.API.csproj +++ b/src/Services/Basket/Basket.API/Basket.API.csproj @@ -27,7 +27,7 @@ - + diff --git a/src/Services/Basket/Basket.API/IntegrationEvents/Events/OrderStartedIntegrationEvent.cs b/src/Services/Basket/Basket.API/IntegrationEvents/Events/OrderStartedIntegrationEvent.cs index b78d10c05..cb4a63f32 100644 --- a/src/Services/Basket/Basket.API/IntegrationEvents/Events/OrderStartedIntegrationEvent.cs +++ b/src/Services/Basket/Basket.API/IntegrationEvents/Events/OrderStartedIntegrationEvent.cs @@ -5,9 +5,9 @@ namespace Basket.API.IntegrationEvents.Events // Integration Events notes: // 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. - public class OrderStartedIntegrationEvent : IntegrationEvent + public record OrderStartedIntegrationEvent : IntegrationEvent { - public string UserId { get; set; } + public string UserId { get; init; } public OrderStartedIntegrationEvent(string userId) => UserId = userId; diff --git a/src/Services/Basket/Basket.API/IntegrationEvents/Events/ProductPriceChangedIntegrationEvent.cs b/src/Services/Basket/Basket.API/IntegrationEvents/Events/ProductPriceChangedIntegrationEvent.cs index 6f51010be..a06947b65 100644 --- a/src/Services/Basket/Basket.API/IntegrationEvents/Events/ProductPriceChangedIntegrationEvent.cs +++ b/src/Services/Basket/Basket.API/IntegrationEvents/Events/ProductPriceChangedIntegrationEvent.cs @@ -5,13 +5,13 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.Even // Integration Events notes: // 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. - 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) { diff --git a/src/Services/Basket/Basket.API/IntegrationEvents/Events/UserCheckoutAcceptedIntegrationEvent.cs b/src/Services/Basket/Basket.API/IntegrationEvents/Events/UserCheckoutAcceptedIntegrationEvent.cs index 18d522cf6..e79e0fbdd 100644 --- a/src/Services/Basket/Basket.API/IntegrationEvents/Events/UserCheckoutAcceptedIntegrationEvent.cs +++ b/src/Services/Basket/Basket.API/IntegrationEvents/Events/UserCheckoutAcceptedIntegrationEvent.cs @@ -4,37 +4,37 @@ using System; namespace Basket.API.IntegrationEvents.Events { - public class UserCheckoutAcceptedIntegrationEvent : IntegrationEvent + public record UserCheckoutAcceptedIntegrationEvent : IntegrationEvent { public string UserId { 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; } diff --git a/src/Services/Basket/Basket.API/Model/BasketCheckout.cs b/src/Services/Basket/Basket.API/Model/BasketCheckout.cs index 70173611f..410700773 100644 --- a/src/Services/Basket/Basket.API/Model/BasketCheckout.cs +++ b/src/Services/Basket/Basket.API/Model/BasketCheckout.cs @@ -2,29 +2,29 @@ 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; } } diff --git a/src/Services/Basket/Basket.API/Model/BasketItem.cs b/src/Services/Basket/Basket.API/Model/BasketItem.cs index e0414884c..4d2e4f331 100644 --- a/src/Services/Basket/Basket.API/Model/BasketItem.cs +++ b/src/Services/Basket/Basket.API/Model/BasketItem.cs @@ -3,15 +3,15 @@ using System.ComponentModel.DataAnnotations; namespace Microsoft.eShopOnContainers.Services.Basket.API.Model { - public record BasketItem : IValidatableObject + public class BasketItem : IValidatableObject { - public string Id { get; init; } - public int ProductId { get; init; } - public string ProductName { get; init; } + public string Id { get; set; } + public int ProductId { get; set; } + public string ProductName { get; set; } public decimal UnitPrice { get; set; } public decimal OldUnitPrice { get; set; } - public int Quantity { get; init; } - public string PictureUrl { get; init; } + public int Quantity { get; set; } + public string PictureUrl { get; set; } public IEnumerable Validate(ValidationContext validationContext) { var results = new List(); diff --git a/src/Services/Basket/Basket.API/Model/CustomerBasket.cs b/src/Services/Basket/Basket.API/Model/CustomerBasket.cs index e8dc14edb..9ae495d4f 100644 --- a/src/Services/Basket/Basket.API/Model/CustomerBasket.cs +++ b/src/Services/Basket/Basket.API/Model/CustomerBasket.cs @@ -2,9 +2,9 @@ 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 Items { get; set; } = new List(); diff --git a/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStatusChangedToAwaitingValidationIntegrationEvent.cs b/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStatusChangedToAwaitingValidationIntegrationEvent.cs index 9787aaedd..b1061f60e 100644 --- a/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStatusChangedToAwaitingValidationIntegrationEvent.cs +++ b/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStatusChangedToAwaitingValidationIntegrationEvent.cs @@ -3,7 +3,7 @@ using BuildingBlocks.EventBus.Events; using System.Collections.Generic; - public class OrderStatusChangedToAwaitingValidationIntegrationEvent : IntegrationEvent + public record OrderStatusChangedToAwaitingValidationIntegrationEvent : IntegrationEvent { public int OrderId { get; } public IEnumerable OrderStockItems { get; } @@ -16,7 +16,7 @@ } } - public class OrderStockItem + public record OrderStockItem { public int ProductId { get; } public int Units { get; } diff --git a/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStatusChangedToPaidIntegrationEvent.cs b/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStatusChangedToPaidIntegrationEvent.cs index 881aa21fe..d5a295cc5 100644 --- a/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStatusChangedToPaidIntegrationEvent.cs +++ b/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStatusChangedToPaidIntegrationEvent.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; - public class OrderStatusChangedToPaidIntegrationEvent : IntegrationEvent + public record OrderStatusChangedToPaidIntegrationEvent : IntegrationEvent { public int OrderId { get; } public IEnumerable OrderStockItems { get; } diff --git a/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStockConfirmedIntegrationEvent.cs b/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStockConfirmedIntegrationEvent.cs index b91eaae43..6c6a3cfa4 100644 --- a/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStockConfirmedIntegrationEvent.cs +++ b/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStockConfirmedIntegrationEvent.cs @@ -2,7 +2,7 @@ { using BuildingBlocks.EventBus.Events; - public class OrderStockConfirmedIntegrationEvent : IntegrationEvent + public record OrderStockConfirmedIntegrationEvent : IntegrationEvent { public int OrderId { get; } diff --git a/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStockRejectedIntegrationEvent.cs b/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStockRejectedIntegrationEvent.cs index eb74af8dd..7c098edf4 100644 --- a/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStockRejectedIntegrationEvent.cs +++ b/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStockRejectedIntegrationEvent.cs @@ -3,7 +3,7 @@ using BuildingBlocks.EventBus.Events; using System.Collections.Generic; - public class OrderStockRejectedIntegrationEvent : IntegrationEvent + public record OrderStockRejectedIntegrationEvent : IntegrationEvent { public int OrderId { get; } @@ -17,7 +17,7 @@ } } - public class ConfirmedOrderStockItem + public record ConfirmedOrderStockItem { public int ProductId { get; } public bool HasStock { get; } diff --git a/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/ProductPriceChangedIntegrationEvent.cs b/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/ProductPriceChangedIntegrationEvent.cs index 00f25b9e5..004c938a1 100644 --- a/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/ProductPriceChangedIntegrationEvent.cs +++ b/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/ProductPriceChangedIntegrationEvent.cs @@ -5,13 +5,13 @@ // Integration Events notes: // 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. - 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) { diff --git a/src/Services/Catalog/Catalog.FunctionalTests/Catalog.FunctionalTests.csproj b/src/Services/Catalog/Catalog.FunctionalTests/Catalog.FunctionalTests.csproj index 245f889dc..7b584d913 100644 --- a/src/Services/Catalog/Catalog.FunctionalTests/Catalog.FunctionalTests.csproj +++ b/src/Services/Catalog/Catalog.FunctionalTests/Catalog.FunctionalTests.csproj @@ -33,10 +33,10 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers diff --git a/src/Services/Catalog/Catalog.UnitTests/Catalog.UnitTests.csproj b/src/Services/Catalog/Catalog.UnitTests/Catalog.UnitTests.csproj index f92c1a0d2..473c1707e 100644 --- a/src/Services/Catalog/Catalog.UnitTests/Catalog.UnitTests.csproj +++ b/src/Services/Catalog/Catalog.UnitTests/Catalog.UnitTests.csproj @@ -7,11 +7,11 @@ - - - - - + + + + + all runtime; build; native; contentfiles; analyzers diff --git a/src/Services/Identity/Identity.API/Identity.API.csproj b/src/Services/Identity/Identity.API/Identity.API.csproj index 6245700d2..f301ab13b 100644 --- a/src/Services/Identity/Identity.API/Identity.API.csproj +++ b/src/Services/Identity/Identity.API/Identity.API.csproj @@ -16,39 +16,40 @@ - - - + + + - - - + + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - + + + + + + + - + - + + diff --git a/src/Services/Identity/Identity.API/Startup.cs b/src/Services/Identity/Identity.API/Startup.cs index 0053cf3ae..f6fd57131 100644 --- a/src/Services/Identity/Identity.API/Startup.cs +++ b/src/Services/Identity/Identity.API/Startup.cs @@ -128,7 +128,6 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); - app.UseDatabaseErrorPage(); } else { diff --git a/src/Services/Ordering/Ordering.API/Application/Commands/CancelOrderCommand.cs b/src/Services/Ordering/Ordering.API/Application/Commands/CancelOrderCommand.cs index c2a1c2be5..77433f161 100644 --- a/src/Services/Ordering/Ordering.API/Application/Commands/CancelOrderCommand.cs +++ b/src/Services/Ordering/Ordering.API/Application/Commands/CancelOrderCommand.cs @@ -11,7 +11,7 @@ namespace Ordering.API.Application.Commands { [DataMember] - public int OrderNumber { get; private set; } + public int OrderNumber { get; set; } public CancelOrderCommand() { diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/GracePeriodConfirmedIntegrationEvent.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/GracePeriodConfirmedIntegrationEvent.cs index 15b0aebb5..1eac25205 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/GracePeriodConfirmedIntegrationEvent.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/GracePeriodConfirmedIntegrationEvent.cs @@ -2,7 +2,7 @@ { using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; - public class GracePeriodConfirmedIntegrationEvent : IntegrationEvent + public record GracePeriodConfirmedIntegrationEvent : IntegrationEvent { public int OrderId { get; } diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderPaymentFailedIntegrationEvent .cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderPaymentFailedIntegrationEvent .cs index fec066521..a4d1c70f6 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderPaymentFailedIntegrationEvent .cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderPaymentFailedIntegrationEvent .cs @@ -2,7 +2,7 @@ { using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; - public class OrderPaymentFailedIntegrationEvent : IntegrationEvent + public record OrderPaymentFailedIntegrationEvent : IntegrationEvent { public int OrderId { get; } diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderPaymentSucceededIntegrationEvent.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderPaymentSucceededIntegrationEvent.cs index 9b220c7b7..8897deb31 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderPaymentSucceededIntegrationEvent.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderPaymentSucceededIntegrationEvent.cs @@ -2,7 +2,7 @@ { using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; - public class OrderPaymentSucceededIntegrationEvent : IntegrationEvent + public record OrderPaymentSucceededIntegrationEvent : IntegrationEvent { public int OrderId { get; } diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStartedIntegrationEvent.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStartedIntegrationEvent.cs index 4a5d7db38..a47fb7988 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStartedIntegrationEvent.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStartedIntegrationEvent.cs @@ -9,7 +9,7 @@ namespace Ordering.API.Application.IntegrationEvents.Events // Integration Events notes: // 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. - public class OrderStartedIntegrationEvent : IntegrationEvent + public record OrderStartedIntegrationEvent : IntegrationEvent { public string UserId { get; set; } diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStatusChangedToAwaitingValidationIntegrationEvent.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStatusChangedToAwaitingValidationIntegrationEvent.cs index a104215af..673b445cf 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStatusChangedToAwaitingValidationIntegrationEvent.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStatusChangedToAwaitingValidationIntegrationEvent.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; - public class OrderStatusChangedToAwaitingValidationIntegrationEvent : IntegrationEvent + public record OrderStatusChangedToAwaitingValidationIntegrationEvent : IntegrationEvent { public int OrderId { get; } public string OrderStatus { get; } @@ -20,7 +20,7 @@ } } - public class OrderStockItem + public record OrderStockItem { public int ProductId { get; } public int Units { get; } diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStatusChangedToCancelledIntegrationEvent.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStatusChangedToCancelledIntegrationEvent.cs index 6ff92a1d3..34524f0c0 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStatusChangedToCancelledIntegrationEvent.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStatusChangedToCancelledIntegrationEvent.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace Ordering.API.Application.IntegrationEvents.Events { - public class OrderStatusChangedToCancelledIntegrationEvent : IntegrationEvent + public record OrderStatusChangedToCancelledIntegrationEvent : IntegrationEvent { public int OrderId { get; } public string OrderStatus { get; } diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStatusChangedToPaidIntegrationEvent.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStatusChangedToPaidIntegrationEvent.cs index 6bcbc3494..50d6f7e72 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStatusChangedToPaidIntegrationEvent.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStatusChangedToPaidIntegrationEvent.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; - public class OrderStatusChangedToPaidIntegrationEvent : IntegrationEvent + public record OrderStatusChangedToPaidIntegrationEvent : IntegrationEvent { public int OrderId { get; } public string OrderStatus { get; } diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStatusChangedToShippedIntegrationEvent.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStatusChangedToShippedIntegrationEvent.cs index 1753fcc78..dc48ac06d 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStatusChangedToShippedIntegrationEvent.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStatusChangedToShippedIntegrationEvent.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace Ordering.API.Application.IntegrationEvents.Events { - public class OrderStatusChangedToShippedIntegrationEvent : IntegrationEvent + public record OrderStatusChangedToShippedIntegrationEvent : IntegrationEvent { public int OrderId { get; } public string OrderStatus { get; } diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStatusChangedToStockConfirmedIntegrationEvent.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStatusChangedToStockConfirmedIntegrationEvent.cs index 24e51f55b..d87e30b81 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStatusChangedToStockConfirmedIntegrationEvent.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStatusChangedToStockConfirmedIntegrationEvent.cs @@ -2,7 +2,7 @@ { using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; - public class OrderStatusChangedToStockConfirmedIntegrationEvent : IntegrationEvent + public record OrderStatusChangedToStockConfirmedIntegrationEvent : IntegrationEvent { public int OrderId { get; } public string OrderStatus { get; } diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStatusChangedTosubmittedIntegrationEvent.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStatusChangedTosubmittedIntegrationEvent.cs index 816c8bddf..82f1125da 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStatusChangedTosubmittedIntegrationEvent.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStatusChangedTosubmittedIntegrationEvent.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace Ordering.API.Application.IntegrationEvents.Events { - public class OrderStatusChangedToSubmittedIntegrationEvent : IntegrationEvent + public record OrderStatusChangedToSubmittedIntegrationEvent : IntegrationEvent { public int OrderId { get; } public string OrderStatus { get; } diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStockConfirmedIntegrationEvent.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStockConfirmedIntegrationEvent.cs index 4bcc9aab5..2b09c8655 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStockConfirmedIntegrationEvent.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStockConfirmedIntegrationEvent.cs @@ -2,7 +2,7 @@ { using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; - public class OrderStockConfirmedIntegrationEvent : IntegrationEvent + public record OrderStockConfirmedIntegrationEvent : IntegrationEvent { public int OrderId { get; } diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStockRejectedIntegrationEvent.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStockRejectedIntegrationEvent.cs index 647970581..c16148f84 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStockRejectedIntegrationEvent.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStockRejectedIntegrationEvent.cs @@ -3,7 +3,7 @@ using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; using System.Collections.Generic; - public class OrderStockRejectedIntegrationEvent : IntegrationEvent + public record OrderStockRejectedIntegrationEvent : IntegrationEvent { public int OrderId { get; } @@ -17,7 +17,7 @@ } } - public class ConfirmedOrderStockItem + public record ConfirmedOrderStockItem { public int ProductId { get; } public bool HasStock { get; } diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/UserCheckoutAcceptedIntegrationEvent.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/UserCheckoutAcceptedIntegrationEvent.cs index 2cb49aae0..4cd74b16b 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/UserCheckoutAcceptedIntegrationEvent.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/UserCheckoutAcceptedIntegrationEvent.cs @@ -4,7 +4,7 @@ using System; namespace Ordering.API.Application.IntegrationEvents.Events { - public class UserCheckoutAcceptedIntegrationEvent : IntegrationEvent + public record UserCheckoutAcceptedIntegrationEvent : IntegrationEvent { public string UserId { get; } diff --git a/src/Services/Ordering/Ordering.API/Ordering.API.csproj b/src/Services/Ordering/Ordering.API/Ordering.API.csproj index 227141a5b..a6e0c99d2 100644 --- a/src/Services/Ordering/Ordering.API/Ordering.API.csproj +++ b/src/Services/Ordering/Ordering.API/Ordering.API.csproj @@ -52,7 +52,7 @@ - + diff --git a/src/Services/Ordering/Ordering.BackgroundTasks/Events/GracePeriodConfirmedIntegrationEvent.cs b/src/Services/Ordering/Ordering.BackgroundTasks/Events/GracePeriodConfirmedIntegrationEvent.cs index 8fe92df76..e6b4f4dc7 100644 --- a/src/Services/Ordering/Ordering.BackgroundTasks/Events/GracePeriodConfirmedIntegrationEvent.cs +++ b/src/Services/Ordering/Ordering.BackgroundTasks/Events/GracePeriodConfirmedIntegrationEvent.cs @@ -2,7 +2,7 @@ { using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; - public class GracePeriodConfirmedIntegrationEvent : IntegrationEvent + public record GracePeriodConfirmedIntegrationEvent : IntegrationEvent { public int OrderId { get; } diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToAwaitingValidationIntegrationEvent.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToAwaitingValidationIntegrationEvent.cs index 2c5ecee27..c1a3e0a27 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToAwaitingValidationIntegrationEvent.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToAwaitingValidationIntegrationEvent.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; namespace Ordering.SignalrHub.IntegrationEvents { - public class OrderStatusChangedToAwaitingValidationIntegrationEvent : IntegrationEvent + public record OrderStatusChangedToAwaitingValidationIntegrationEvent : IntegrationEvent { public int OrderId { get; } public string OrderStatus { get; } diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToCancelledIntegrationEvent.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToCancelledIntegrationEvent.cs index e9ac5b39b..038b14a5a 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToCancelledIntegrationEvent.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToCancelledIntegrationEvent.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace Ordering.SignalrHub.IntegrationEvents.Events { - public class OrderStatusChangedToCancelledIntegrationEvent : IntegrationEvent + public record OrderStatusChangedToCancelledIntegrationEvent : IntegrationEvent { public int OrderId { get; } public string OrderStatus { get; } diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToPaidIntegrationEvent.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToPaidIntegrationEvent.cs index beb49965d..349c9f1a7 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToPaidIntegrationEvent.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToPaidIntegrationEvent.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace Ordering.SignalrHub.IntegrationEvents.Events { - public class OrderStatusChangedToPaidIntegrationEvent : IntegrationEvent + public record OrderStatusChangedToPaidIntegrationEvent : IntegrationEvent { public int OrderId { get; } public string OrderStatus { get; } diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToShippedIntegrationEvent.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToShippedIntegrationEvent.cs index 0768c7f4e..4804dd504 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToShippedIntegrationEvent.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToShippedIntegrationEvent.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace Ordering.SignalrHub.IntegrationEvents.Events { - public class OrderStatusChangedToShippedIntegrationEvent : IntegrationEvent + public record OrderStatusChangedToShippedIntegrationEvent : IntegrationEvent { public int OrderId { get; } public string OrderStatus { get; } diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToStockConfirmedIntegrationEvent.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToStockConfirmedIntegrationEvent.cs index 588505c8f..137967ff6 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToStockConfirmedIntegrationEvent.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToStockConfirmedIntegrationEvent.cs @@ -2,7 +2,7 @@ namespace Ordering.SignalrHub.IntegrationEvents.Events { - public class OrderStatusChangedToStockConfirmedIntegrationEvent : IntegrationEvent + public record OrderStatusChangedToStockConfirmedIntegrationEvent : IntegrationEvent { public int OrderId { get; } public string OrderStatus { get; } diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToSubmittedIntegrationEvent.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToSubmittedIntegrationEvent.cs index 5ea0cec71..3b1e04438 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToSubmittedIntegrationEvent.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToSubmittedIntegrationEvent.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace Ordering.SignalrHub.IntegrationEvents.Events { - public class OrderStatusChangedToSubmittedIntegrationEvent : IntegrationEvent + public record OrderStatusChangedToSubmittedIntegrationEvent : IntegrationEvent { public int OrderId { get; } public string OrderStatus { get; } diff --git a/src/Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj b/src/Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj index d93101961..2aad7d561 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj +++ b/src/Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj @@ -20,7 +20,7 @@ - + diff --git a/src/Services/Payment/Payment.API/IntegrationEvents/Events/OrderPaymentFailedIntegrationEvent.cs b/src/Services/Payment/Payment.API/IntegrationEvents/Events/OrderPaymentFailedIntegrationEvent.cs index d51c518c4..953e5dbaa 100644 --- a/src/Services/Payment/Payment.API/IntegrationEvents/Events/OrderPaymentFailedIntegrationEvent.cs +++ b/src/Services/Payment/Payment.API/IntegrationEvents/Events/OrderPaymentFailedIntegrationEvent.cs @@ -2,7 +2,7 @@ { using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; - public class OrderPaymentFailedIntegrationEvent : IntegrationEvent + public record OrderPaymentFailedIntegrationEvent : IntegrationEvent { public int OrderId { get; } diff --git a/src/Services/Payment/Payment.API/IntegrationEvents/Events/OrderPaymentSucceededIntegrationEvent.cs b/src/Services/Payment/Payment.API/IntegrationEvents/Events/OrderPaymentSucceededIntegrationEvent.cs index 728b0d5a7..317ef8554 100644 --- a/src/Services/Payment/Payment.API/IntegrationEvents/Events/OrderPaymentSucceededIntegrationEvent.cs +++ b/src/Services/Payment/Payment.API/IntegrationEvents/Events/OrderPaymentSucceededIntegrationEvent.cs @@ -2,7 +2,7 @@ { using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; - public class OrderPaymentSucceededIntegrationEvent : IntegrationEvent + public record OrderPaymentSucceededIntegrationEvent : IntegrationEvent { public int OrderId { get; } diff --git a/src/Services/Payment/Payment.API/IntegrationEvents/Events/OrderStatusChangedToStockConfirmedIntegrationEvent.cs b/src/Services/Payment/Payment.API/IntegrationEvents/Events/OrderStatusChangedToStockConfirmedIntegrationEvent.cs index 88f60e0d6..caa3295d5 100644 --- a/src/Services/Payment/Payment.API/IntegrationEvents/Events/OrderStatusChangedToStockConfirmedIntegrationEvent.cs +++ b/src/Services/Payment/Payment.API/IntegrationEvents/Events/OrderStatusChangedToStockConfirmedIntegrationEvent.cs @@ -2,7 +2,7 @@ { using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; - public class OrderStatusChangedToStockConfirmedIntegrationEvent : IntegrationEvent + public record OrderStatusChangedToStockConfirmedIntegrationEvent : IntegrationEvent { public int OrderId { get; } diff --git a/src/Services/Webhooks/Webhooks.API/Dockerfile b/src/Services/Webhooks/Webhooks.API/Dockerfile index c1f031263..67e1c5375 100644 --- a/src/Services/Webhooks/Webhooks.API/Dockerfile +++ b/src/Services/Webhooks/Webhooks.API/Dockerfile @@ -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 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 # It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles diff --git a/src/Services/Webhooks/Webhooks.API/IntegrationEvents/OrderStatusChangedToPaidIntegrationEvent.cs b/src/Services/Webhooks/Webhooks.API/IntegrationEvents/OrderStatusChangedToPaidIntegrationEvent.cs index c4adda56e..3f532ef0a 100644 --- a/src/Services/Webhooks/Webhooks.API/IntegrationEvents/OrderStatusChangedToPaidIntegrationEvent.cs +++ b/src/Services/Webhooks/Webhooks.API/IntegrationEvents/OrderStatusChangedToPaidIntegrationEvent.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace Webhooks.API.IntegrationEvents { - public class OrderStatusChangedToPaidIntegrationEvent : IntegrationEvent + public record OrderStatusChangedToPaidIntegrationEvent : IntegrationEvent { public int OrderId { get; } public IEnumerable OrderStockItems { get; } @@ -19,7 +19,7 @@ namespace Webhooks.API.IntegrationEvents } } - public class OrderStockItem + public record OrderStockItem { public int ProductId { get; } public int Units { get; } diff --git a/src/Services/Webhooks/Webhooks.API/IntegrationEvents/OrderStatusChangedToShippedIntegrationEvent.cs b/src/Services/Webhooks/Webhooks.API/IntegrationEvents/OrderStatusChangedToShippedIntegrationEvent.cs index 10693eb8b..2b03abacf 100644 --- a/src/Services/Webhooks/Webhooks.API/IntegrationEvents/OrderStatusChangedToShippedIntegrationEvent.cs +++ b/src/Services/Webhooks/Webhooks.API/IntegrationEvents/OrderStatusChangedToShippedIntegrationEvent.cs @@ -1,16 +1,12 @@ using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace Webhooks.API.IntegrationEvents { - public class OrderStatusChangedToShippedIntegrationEvent : IntegrationEvent + public record OrderStatusChangedToShippedIntegrationEvent : IntegrationEvent { - public int OrderId { get; private set; } - public string OrderStatus { get; private set; } - public string BuyerName { get; private set; } + public int OrderId { get; private init; } + public string OrderStatus { get; private init; } + public string BuyerName { get; private init; } public OrderStatusChangedToShippedIntegrationEvent(int orderId, string orderStatus, string buyerName) { diff --git a/src/Services/Webhooks/Webhooks.API/IntegrationEvents/ProductPriceChangedIntegrationEvent.cs b/src/Services/Webhooks/Webhooks.API/IntegrationEvents/ProductPriceChangedIntegrationEvent.cs index 18821f9fc..8fb860007 100644 --- a/src/Services/Webhooks/Webhooks.API/IntegrationEvents/ProductPriceChangedIntegrationEvent.cs +++ b/src/Services/Webhooks/Webhooks.API/IntegrationEvents/ProductPriceChangedIntegrationEvent.cs @@ -1,18 +1,14 @@ using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; 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) { diff --git a/src/Services/Webhooks/Webhooks.API/Program.cs b/src/Services/Webhooks/Webhooks.API/Program.cs index b08a1c2da..b7ed97115 100644 --- a/src/Services/Webhooks/Webhooks.API/Program.cs +++ b/src/Services/Webhooks/Webhooks.API/Program.cs @@ -7,20 +7,15 @@ using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; +using Webhooks.API; using Webhooks.API.Infrastructure; -namespace Webhooks.API -{ - public class Program - { - public static void Main(string[] args) - { - CreateWebHostBuilder(args).Build() - .MigrateDbContext((_,__) => { }) - .Run(); - } +CreateWebHostBuilder(args).Build() + .MigrateDbContext((_, __) => { }) + .Run(); - public static IWebHostBuilder CreateWebHostBuilder(string[] args) => + +IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup() .ConfigureAppConfiguration((builderContext, config) => @@ -33,6 +28,4 @@ namespace Webhooks.API builder.AddConsole(); builder.AddDebug(); builder.AddAzureWebAppDiagnostics(); - }); - } -} + }); \ No newline at end of file diff --git a/src/Services/Webhooks/Webhooks.API/Startup.cs b/src/Services/Webhooks/Webhooks.API/Startup.cs index c8073e1a0..7fab9c72a 100644 --- a/src/Services/Webhooks/Webhooks.API/Startup.cs +++ b/src/Services/Webhooks/Webhooks.API/Startup.cs @@ -174,11 +174,6 @@ namespace Webhooks.API //Configuring Connection Resiliency: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency 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; diff --git a/src/Services/Webhooks/Webhooks.API/Webhooks.API.csproj b/src/Services/Webhooks/Webhooks.API/Webhooks.API.csproj index 6624001c4..a11dc87fe 100644 --- a/src/Services/Webhooks/Webhooks.API/Webhooks.API.csproj +++ b/src/Services/Webhooks/Webhooks.API/Webhooks.API.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 InProcess Linux $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; @@ -11,18 +11,18 @@ - - - - - - - + + + + + + + - - - + + + diff --git a/src/Tests/Services/Application.FunctionalTests/Middleware/AutoAuthorizeMiddleware.cs b/src/Tests/Services/Application.FunctionalTests/Middleware/AutoAuthorizeMiddleware.cs index 65206db4f..d2f8a55f8 100644 --- a/src/Tests/Services/Application.FunctionalTests/Middleware/AutoAuthorizeMiddleware.cs +++ b/src/Tests/Services/Application.FunctionalTests/Middleware/AutoAuthorizeMiddleware.cs @@ -25,6 +25,7 @@ namespace FunctionalTests.Middleware identity.AddClaim(new Claim("sub", IDENTITY_ID)); identity.AddClaim(new Claim("unique_name", IDENTITY_ID)); + identity.AddClaim(new Claim(ClaimTypes.Name, IDENTITY_ID)); httpContext.User.AddIdentity(identity); await _next.Invoke(httpContext); diff --git a/src/Tests/Services/Application.FunctionalTests/Services/Ordering/OrderingTestsStartup.cs b/src/Tests/Services/Application.FunctionalTests/Services/Ordering/OrderingTestsStartup.cs index 46e5fe8c1..41dd9a989 100644 --- a/src/Tests/Services/Application.FunctionalTests/Services/Ordering/OrderingTestsStartup.cs +++ b/src/Tests/Services/Application.FunctionalTests/Services/Ordering/OrderingTestsStartup.cs @@ -20,6 +20,7 @@ namespace FunctionalTests.Services.Ordering if (Configuration["isTest"] == bool.TrueString.ToLowerInvariant()) { app.UseMiddleware(); + app.UseAuthorization(); } else { diff --git a/src/Tests/Services/Application.FunctionalTests/Services/Ordering/appsettings.json b/src/Tests/Services/Application.FunctionalTests/Services/Ordering/appsettings.json index 70f1af3c0..b94888de2 100644 --- a/src/Tests/Services/Application.FunctionalTests/Services/Ordering/appsettings.json +++ b/src/Tests/Services/Application.FunctionalTests/Services/Ordering/appsettings.json @@ -6,5 +6,6 @@ "EventBusConnection": "localhost", "CheckUpdateTime": "30000", "GracePeriodTime": "1", - "SubscriptionClientName": "Ordering" + "SubscriptionClientName": "Ordering", + "IdentityUrlExternal": "http://localhost:5105" } diff --git a/src/Web/WebMVC/Dockerfile b/src/Web/WebMVC/Dockerfile index acf02ae53..a99a72c6f 100644 --- a/src/Web/WebMVC/Dockerfile +++ b/src/Web/WebMVC/Dockerfile @@ -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 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 # It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles diff --git a/src/Web/WebMVC/Program.cs b/src/Web/WebMVC/Program.cs index eb99cd42e..a95578718 100644 --- a/src/Web/WebMVC/Program.cs +++ b/src/Web/WebMVC/Program.cs @@ -1,79 +1,77 @@ using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.eShopOnContainers.WebMVC; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using Serilog; using System; 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); + + 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() + .UseSerilog() + .Build(); + +Serilog.ILogger CreateSerilogLogger(IConfiguration configuration) +{ + var seqServerUrl = configuration["Serilog:SeqServerUrl"]; + var logstashUrl = configuration["Serilog:LogstashgUrl"]; + var cfg = new LoggerConfiguration() + .ReadFrom.Configuration(configuration) + .Enrich.WithProperty("ApplicationContext", Program.AppName) + .Enrich.FromLogContext() + .WriteTo.Console(); + if (!string.IsNullOrWhiteSpace(seqServerUrl)) { - 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) - { - var configuration = GetConfiguration(); - - Log.Logger = CreateSerilogLogger(configuration); - - try - { - Log.Information("Configuring web host ({ApplicationContext})...", AppName); - var host = BuildWebHost(configuration, args); - - 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() - .UseSerilog() - .Build(); - - private static Serilog.ILogger CreateSerilogLogger(IConfiguration configuration) - { - var seqServerUrl = configuration["Serilog:SeqServerUrl"]; - var logstashUrl = configuration["Serilog:LogstashgUrl"]; - var cfg = new LoggerConfiguration() - .ReadFrom.Configuration(configuration) - .Enrich.WithProperty("ApplicationContext", AppName) - .Enrich.FromLogContext() - .WriteTo.Console(); - if (!string.IsNullOrWhiteSpace(seqServerUrl)) { - cfg.WriteTo.Seq(seqServerUrl); - } - if (!string.IsNullOrWhiteSpace(logstashUrl)) { - cfg.WriteTo.Http(logstashUrl); - } - return cfg.CreateLogger(); - } - - private static IConfiguration GetConfiguration() - { - var builder = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) - .AddEnvironmentVariables(); - - return builder.Build(); - } + cfg.WriteTo.Seq(seqServerUrl); } + if (!string.IsNullOrWhiteSpace(logstashUrl)) + { + cfg.WriteTo.Http(logstashUrl); + } + return cfg.CreateLogger(); +} + +IConfiguration GetConfiguration() +{ + var builder = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) + .AddEnvironmentVariables(); + + return builder.Build(); +} + + +public class Program +{ + private static readonly string _namespace = typeof(Startup).Namespace; + public static readonly string AppName = _namespace.Substring(_namespace.LastIndexOf('.', _namespace.LastIndexOf('.') - 1) + 1); } \ No newline at end of file diff --git a/src/Web/WebMVC/Services/ModelDTOs/BasketDTO.cs b/src/Web/WebMVC/Services/ModelDTOs/BasketDTO.cs index 130a729f5..bff5ec10b 100644 --- a/src/Web/WebMVC/Services/ModelDTOs/BasketDTO.cs +++ b/src/Web/WebMVC/Services/ModelDTOs/BasketDTO.cs @@ -3,35 +3,35 @@ using System.ComponentModel.DataAnnotations; namespace WebMVC.Services.ModelDTOs { - public class BasketDTO + public record BasketDTO { [Required] - public string City { get; set; } + public string City { get; init; } [Required] - public string Street { get; set; } + public string Street { get; init; } [Required] - public string State { get; set; } + public string State { get; init; } [Required] - public string Country { get; set; } + public string Country { get; init; } - public string ZipCode { get; set; } + public string ZipCode { get; init; } [Required] - public string CardNumber { get; set; } + public string CardNumber { get; init; } [Required] - public string CardHolderName { get; set; } + public string CardHolderName { get; init; } [Required] - public DateTime CardExpiration { get; set; } + public DateTime CardExpiration { get; init; } [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] - public Guid RequestId { get; set; } + public Guid RequestId { get; init; } } } diff --git a/src/Web/WebMVC/Services/ModelDTOs/LocationDTO.cs b/src/Web/WebMVC/Services/ModelDTOs/LocationDTO.cs index 0bff03604..626b2b2d3 100644 --- a/src/Web/WebMVC/Services/ModelDTOs/LocationDTO.cs +++ b/src/Web/WebMVC/Services/ModelDTOs/LocationDTO.cs @@ -1,8 +1,8 @@ namespace WebMVC.Services.ModelDTOs { - public class LocationDTO + public record LocationDTO { - public double Longitude { get; set; } - public double Latitude { get; set; } + public double Longitude { get; init; } + public double Latitude { get; init; } } } diff --git a/src/Web/WebMVC/Services/ModelDTOs/OrderDTO.cs b/src/Web/WebMVC/Services/ModelDTOs/OrderDTO.cs index aabfb5b5f..f88cf22f8 100644 --- a/src/Web/WebMVC/Services/ModelDTOs/OrderDTO.cs +++ b/src/Web/WebMVC/Services/ModelDTOs/OrderDTO.cs @@ -2,9 +2,9 @@ namespace WebMVC.Services.ModelDTOs { - public class OrderDTO + public record OrderDTO { [Required] - public string OrderNumber { get; set; } + public string OrderNumber { get; init; } } } \ No newline at end of file diff --git a/src/Web/WebMVC/Services/ModelDTOs/OrderProcessAction.cs b/src/Web/WebMVC/Services/ModelDTOs/OrderProcessAction.cs index 065f53dbc..34e4a2695 100644 --- a/src/Web/WebMVC/Services/ModelDTOs/OrderProcessAction.cs +++ b/src/Web/WebMVC/Services/ModelDTOs/OrderProcessAction.cs @@ -1,9 +1,9 @@ namespace WebMVC.Services.ModelDTOs { - public class OrderProcessAction + public record OrderProcessAction { - public string Code { get; private set; } - public string Name { get; private set; } + public string Code { get; } + public string Name { get; } public static OrderProcessAction Ship = new OrderProcessAction(nameof(Ship).ToLowerInvariant(), "Ship"); diff --git a/src/Web/WebMVC/Startup.cs b/src/Web/WebMVC/Startup.cs index f4570c71e..59942e27c 100644 --- a/src/Web/WebMVC/Startup.cs +++ b/src/Web/WebMVC/Startup.cs @@ -7,19 +7,16 @@ using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Diagnostics.HealthChecks; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; using Microsoft.eShopOnContainers.WebMVC.Services; using Microsoft.eShopOnContainers.WebMVC.ViewModels; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Diagnostics.HealthChecks; using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; using Microsoft.IdentityModel.Logging; using StackExchange.Redis; using System; using System.IdentityModel.Tokens.Jwt; -using System.Net.Http; using WebMVC.Infrastructure; using WebMVC.Infrastructure.Middlewares; using WebMVC.Services; diff --git a/src/Web/WebMVC/ViewModels/Basket.cs b/src/Web/WebMVC/ViewModels/Basket.cs index b95a910a2..bafb3cbe8 100644 --- a/src/Web/WebMVC/ViewModels/Basket.cs +++ b/src/Web/WebMVC/ViewModels/Basket.cs @@ -1,18 +1,17 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; namespace Microsoft.eShopOnContainers.WebMVC.ViewModels { - public class Basket + public record Basket { // Use property initializer syntax. // While this is often more useful for read only // auto implemented properties, it can simplify logic // for read/write properties. - public List Items { get; set; } = new List(); - public string BuyerId { get; set; } + public List Items { get; init; } = new List(); + public string BuyerId { get; init; } public decimal Total() { diff --git a/src/Web/WebMVC/ViewModels/BasketItem.cs b/src/Web/WebMVC/ViewModels/BasketItem.cs index ab767f8f5..115871f96 100644 --- a/src/Web/WebMVC/ViewModels/BasketItem.cs +++ b/src/Web/WebMVC/ViewModels/BasketItem.cs @@ -1,18 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Microsoft.eShopOnContainers.WebMVC.ViewModels +namespace Microsoft.eShopOnContainers.WebMVC.ViewModels { - public class BasketItem + public record BasketItem { - public string Id { get; set; } - public string ProductId { get; set; } - public string ProductName { get; set; } - public decimal UnitPrice { get; set; } - public decimal OldUnitPrice { get; set; } - public int Quantity { get; set; } - public string PictureUrl { get; set; } + public string Id { get; init; } + public string ProductId { get; init; } + public string ProductName { get; init; } + public decimal UnitPrice { get; init; } + public decimal OldUnitPrice { get; init; } + public int Quantity { get; init; } + public string PictureUrl { get; init; } } } diff --git a/src/Web/WebMVC/ViewModels/Campaign.cs b/src/Web/WebMVC/ViewModels/Campaign.cs index 11841fc3f..eae64c39c 100644 --- a/src/Web/WebMVC/ViewModels/Campaign.cs +++ b/src/Web/WebMVC/ViewModels/Campaign.cs @@ -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 PageSize { get; set; } - public int Count { get; set; } - public List Data { get; set; } + public int PageIndex { get; init; } + public int PageSize { get; init; } + public int Count { get; init; } + public List Data { get; init; } } } \ No newline at end of file diff --git a/src/Web/WebMVC/ViewModels/CampaignItem.cs b/src/Web/WebMVC/ViewModels/CampaignItem.cs index 04e220229..df5639fc2 100644 --- a/src/Web/WebMVC/ViewModels/CampaignItem.cs +++ b/src/Web/WebMVC/ViewModels/CampaignItem.cs @@ -1,20 +1,20 @@ -namespace Microsoft.eShopOnContainers.WebMVC.ViewModels +using System; + +namespace Microsoft.eShopOnContainers.WebMVC.ViewModels { - using System; - - public class CampaignItem + public record 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 DetailsUri { get; set; } + public string PictureUri { get; init; } + public string DetailsUri { get; init; } } } \ No newline at end of file diff --git a/src/Web/WebMVC/ViewModels/CartViewModels/IndexViewModel.cs b/src/Web/WebMVC/ViewModels/CartViewModels/IndexViewModel.cs index 9a8802542..be7d6dd1f 100644 --- a/src/Web/WebMVC/ViewModels/CartViewModels/IndexViewModel.cs +++ b/src/Web/WebMVC/ViewModels/CartViewModels/IndexViewModel.cs @@ -1,10 +1,4 @@ -using Microsoft.AspNetCore.Mvc.Rendering; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Microsoft.eShopOnContainers.WebMVC.ViewModels.CartViewModels +namespace Microsoft.eShopOnContainers.WebMVC.ViewModels.CartViewModels { public class CartComponentViewModel { diff --git a/src/Web/WebMVC/ViewModels/Catalog.cs b/src/Web/WebMVC/ViewModels/Catalog.cs index d36968565..60a9cc506 100644 --- a/src/Web/WebMVC/ViewModels/Catalog.cs +++ b/src/Web/WebMVC/ViewModels/Catalog.cs @@ -1,15 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using System.Collections.Generic; namespace Microsoft.eShopOnContainers.WebMVC.ViewModels { - public class Catalog + public record Catalog { - public int PageIndex { get; set; } - public int PageSize { get; set; } - public int Count { get; set; } - public List Data { get; set; } + public int PageIndex { get; init; } + public int PageSize { get; init; } + public int Count { get; init; } + public List Data { get; init; } } } diff --git a/src/Web/WebMVC/ViewModels/CatalogItem.cs b/src/Web/WebMVC/ViewModels/CatalogItem.cs index c869b7382..7663fdf5c 100644 --- a/src/Web/WebMVC/ViewModels/CatalogItem.cs +++ b/src/Web/WebMVC/ViewModels/CatalogItem.cs @@ -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 string Name { get; set; } - public string Description { get; set; } - public decimal Price { get; set; } - public string PictureUri { get; set; } - public int CatalogBrandId { get; set; } - public string CatalogBrand { get; set; } - public int CatalogTypeId { get; set; } - public string CatalogType { get; set; } - + public int Id { get; init; } + public string Name { get; init; } + public string Description { get; init; } + public decimal Price { get; init; } + public string PictureUri { get; init; } + public int CatalogBrandId { get; init; } + public string CatalogBrand { get; init; } + public int CatalogTypeId { get; init; } + public string CatalogType { get; init; } } } \ No newline at end of file diff --git a/src/Web/WebMVC/ViewModels/CatalogViewModels/IndexViewModel.cs b/src/Web/WebMVC/ViewModels/CatalogViewModels/IndexViewModel.cs index ab14b4ee4..8f70b32d9 100644 --- a/src/Web/WebMVC/ViewModels/CatalogViewModels/IndexViewModel.cs +++ b/src/Web/WebMVC/ViewModels/CatalogViewModels/IndexViewModel.cs @@ -1,9 +1,6 @@ using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.eShopOnContainers.WebMVC.ViewModels.Pagination; -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace Microsoft.eShopOnContainers.WebMVC.ViewModels.CatalogViewModels { diff --git a/src/Web/WebMVC/ViewModels/Header.cs b/src/Web/WebMVC/ViewModels/Header.cs index 212638fbc..ba1126fad 100644 --- a/src/Web/WebMVC/ViewModels/Header.cs +++ b/src/Web/WebMVC/ViewModels/Header.cs @@ -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 Text { get; set; } + public string Controller { get; init; } + public string Text { get; init; } } } \ No newline at end of file diff --git a/src/Web/WebMVC/ViewModels/OrderItem.cs b/src/Web/WebMVC/ViewModels/OrderItem.cs index 3ba03b96a..c63dcc988 100644 --- a/src/Web/WebMVC/ViewModels/OrderItem.cs +++ b/src/Web/WebMVC/ViewModels/OrderItem.cs @@ -1,22 +1,17 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Microsoft.eShopOnContainers.WebMVC.ViewModels +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; } } } diff --git a/src/Web/WebMVC/ViewModels/Pagination/PaginationInfo.cs b/src/Web/WebMVC/ViewModels/Pagination/PaginationInfo.cs index 0baf8e961..a10280659 100644 --- a/src/Web/WebMVC/ViewModels/Pagination/PaginationInfo.cs +++ b/src/Web/WebMVC/ViewModels/Pagination/PaginationInfo.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Microsoft.eShopOnContainers.WebMVC.ViewModels.Pagination +namespace Microsoft.eShopOnContainers.WebMVC.ViewModels.Pagination { public class PaginationInfo { diff --git a/src/Web/WebMVC/WebMVC.csproj b/src/Web/WebMVC/WebMVC.csproj index 16a094ab9..ec344adf6 100644 --- a/src/Web/WebMVC/WebMVC.csproj +++ b/src/Web/WebMVC/WebMVC.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 aspnet-Microsoft.eShopOnContainers-946ae052-8305-4a99-965b-ec8636ddbae3 ..\..\..\docker-compose.dcproj 3.0 @@ -23,25 +23,25 @@ - - - - - - - + + + + + + + - - - - + + + + - + diff --git a/src/Web/WebSPA/Dockerfile b/src/Web/WebSPA/Dockerfile index 4dc0487ec..2a06e086e 100644 --- a/src/Web/WebSPA/Dockerfile +++ b/src/Web/WebSPA/Dockerfile @@ -1,5 +1,5 @@ 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 EXPOSE 80 @@ -10,7 +10,7 @@ COPY Web/WebSPA/package-lock.json . COPY Web/WebSPA . 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 # It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles diff --git a/src/Web/WebSPA/Program.cs b/src/Web/WebSPA/Program.cs index d8b138e47..5e329981e 100644 --- a/src/Web/WebSPA/Program.cs +++ b/src/Web/WebSPA/Program.cs @@ -4,38 +4,30 @@ using System.IO; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Configuration; using Serilog; +using eShopConContainers.WebSPA; -namespace eShopConContainers.WebSPA -{ - public class Program - { - public static void Main(string[] args) +BuildWebHost(args).Run(); + +IWebHost BuildWebHost(string[] args) => + WebHost.CreateDefaultBuilder(args) + .UseStartup() + .UseContentRoot(Directory.GetCurrentDirectory()) + .ConfigureAppConfiguration((builderContext, config) => { - BuildWebHost(args).Run(); - } - - public static IWebHost BuildWebHost(string[] args) => - WebHost.CreateDefaultBuilder(args) - .UseStartup() - .UseContentRoot(Directory.GetCurrentDirectory()) - .ConfigureAppConfiguration((builderContext, config) => - { - config.AddEnvironmentVariables(); - }) - .ConfigureLogging((hostingContext, builder) => - { - builder.AddConfiguration(hostingContext.Configuration.GetSection("Logging")); - builder.AddConsole(); - builder.AddDebug(); - builder.AddAzureWebAppDiagnostics(); - }) - .UseSerilog((builderContext, config) => - { - config - .MinimumLevel.Information() - .Enrich.FromLogContext() - .WriteTo.Console(); - }) - .Build(); - } -} + config.AddEnvironmentVariables(); + }) + .ConfigureLogging((hostingContext, builder) => + { + builder.AddConfiguration(hostingContext.Configuration.GetSection("Logging")); + builder.AddConsole(); + builder.AddDebug(); + builder.AddAzureWebAppDiagnostics(); + }) + .UseSerilog((builderContext, config) => + { + config + .MinimumLevel.Information() + .Enrich.FromLogContext() + .WriteTo.Console(); + }) + .Build(); diff --git a/src/Web/WebSPA/WebSPA.csproj b/src/Web/WebSPA/WebSPA.csproj index ff161ddc3..3ef697dbb 100644 --- a/src/Web/WebSPA/WebSPA.csproj +++ b/src/Web/WebSPA/WebSPA.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 aspnetcorespa-c23d27a4-eb88-4b18-9b77-2a93f3b15119 ..\..\..\docker-compose.dcproj false @@ -87,16 +87,16 @@ - - - - - + + + + + - + - + diff --git a/src/Web/WebStatus/Dockerfile b/src/Web/WebStatus/Dockerfile index 54f19c516..438837423 100644 --- a/src/Web/WebStatus/Dockerfile +++ b/src/Web/WebStatus/Dockerfile @@ -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 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 # It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles diff --git a/src/Web/WebStatus/Program.cs b/src/Web/WebStatus/Program.cs index cf648daa9..a06f0b142 100644 --- a/src/Web/WebStatus/Program.cs +++ b/src/Web/WebStatus/Program.cs @@ -7,119 +7,114 @@ using System.Collections.Generic; using System.IO; using System.Linq; 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() + .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("UseVault", false)) { - public static readonly string Namespace = typeof(Program).Namespace; - public static readonly string AppName = Namespace; + builder.AddAzureKeyVault( + $"https://{config["Vault:Name"]}.vault.azure.net/", + config["Vault:ClientId"], + config["Vault:ClientSecret"]); + } - public static int Main(string[] args) + return builder.Build(); +} + +string GetVersion(Assembly assembly) +{ + try + { + return $"{assembly.GetCustomAttribute()?.Version} ({assembly.GetCustomAttribute()?.InformationalVersion.Split()[0]})"; + } + catch + { + return string.Empty; + } +} + +void LogPackagesVersionInfo() +{ + var assemblies = new List(); + + foreach (var dependencyName in typeof(Program).Assembly.GetReferencedAssemblies()) + { + try { - var configuration = GetConfiguration(); - - Log.Logger = CreateSerilogLogger(configuration); - - try - { - Log.Information("Configuring web host ({ApplicationContext})...", AppName); - var host = BuildWebHost(configuration, args); - - LogPackagesVersionInfo(); - - 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(); - } + // Try to load the referenced assembly... + assemblies.Add(Assembly.Load(dependencyName)); } - - private static IWebHost BuildWebHost(IConfiguration configuration, string[] args) => - WebHost.CreateDefaultBuilder(args) - .CaptureStartupErrors(false) - .ConfigureAppConfiguration(x => x.AddConfiguration(configuration)) - .UseStartup() - .UseContentRoot(Directory.GetCurrentDirectory()) - .UseSerilog() - .Build(); - - private static Serilog.ILogger CreateSerilogLogger(IConfiguration configuration) + catch { - 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("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()?.Version} ({assembly.GetCustomAttribute()?.InformationalVersion.Split()[0]})"; - } - catch - { - return string.Empty; - } - } - - private static void LogPackagesVersionInfo() - { - var assemblies = new List(); - - 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); + // 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; } \ No newline at end of file diff --git a/src/Web/WebStatus/Startup.cs b/src/Web/WebStatus/Startup.cs index bb7af4ab0..e92217851 100644 --- a/src/Web/WebStatus/Startup.cs +++ b/src/Web/WebStatus/Startup.cs @@ -30,7 +30,10 @@ namespace WebStatus services.AddHealthChecks() .AddCheck("self", () => HealthCheckResult.Healthy()); - services.AddHealthChecksUI(); + services + .AddHealthChecksUI() + .AddInMemoryStorage(); + services.AddMvc() .SetCompatibilityVersion(CompatibilityVersion.Version_3_0); } diff --git a/src/Web/WebStatus/WebStatus.csproj b/src/Web/WebStatus/WebStatus.csproj index ecdf92b15..c90416e0f 100644 --- a/src/Web/WebStatus/WebStatus.csproj +++ b/src/Web/WebStatus/WebStatus.csproj @@ -1,6 +1,6 @@  - netcoreapp3.1 + net5.0 $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; ..\..\..\docker-compose.dcproj true @@ -8,21 +8,22 @@ - - - - - - + + + + + + + - - - - + + + + - + diff --git a/src/Web/WebhookClient/Dockerfile b/src/Web/WebhookClient/Dockerfile index 3b0001032..150049bd9 100644 --- a/src/Web/WebhookClient/Dockerfile +++ b/src/Web/WebhookClient/Dockerfile @@ -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 EXPOSE 80 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 # It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles diff --git a/src/Web/WebhookClient/Program.cs b/src/Web/WebhookClient/Program.cs index ff293ce5a..ffb12b7b2 100644 --- a/src/Web/WebhookClient/Program.cs +++ b/src/Web/WebhookClient/Program.cs @@ -1,24 +1,10 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore; +using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; +using WebhookClient; -namespace WebhookClient -{ - public class Program - { - public static void Main(string[] args) - { - CreateWebHostBuilder(args).Build().Run(); - } +CreateWebHostBuilder(args).Build().Run(); - public static IWebHostBuilder CreateWebHostBuilder(string[] args) => - WebHost.CreateDefaultBuilder(args) - .UseStartup(); - } -} + +IWebHostBuilder CreateWebHostBuilder(string[] args) => + WebHost.CreateDefaultBuilder(args) + .UseStartup(); diff --git a/src/Web/WebhookClient/Services/IWebhooksClient.cs b/src/Web/WebhookClient/Services/IWebhooksClient.cs index 5d14077cc..20238c0a3 100644 --- a/src/Web/WebhookClient/Services/IWebhooksClient.cs +++ b/src/Web/WebhookClient/Services/IWebhooksClient.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; +using System.Collections.Generic; using System.Threading.Tasks; using WebhookClient.Models; diff --git a/src/Web/WebhookClient/Startup.cs b/src/Web/WebhookClient/Startup.cs index e61affd18..f45a30b5d 100644 --- a/src/Web/WebhookClient/Startup.cs +++ b/src/Web/WebhookClient/Startup.cs @@ -61,7 +61,6 @@ namespace WebhookClient 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. } - app.UseAuthentication(); app.Map("/check", capp => { 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.UseSession(); app.UseRouting(); + app.UseAuthentication(); + app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapDefaultControllerRoute(); + endpoints.MapRazorPages(); }); } } diff --git a/src/Web/WebhookClient/WebhookClient.csproj b/src/Web/WebhookClient/WebhookClient.csproj index fbb9f7af9..866f2910a 100644 --- a/src/Web/WebhookClient/WebhookClient.csproj +++ b/src/Web/WebhookClient/WebhookClient.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 InProcess Linux 36215d41-f31a-4aa6-9929-bd67d650e7b5 @@ -14,8 +14,8 @@ - - + +