From eb905aae0184426f28e69b7af3d8dace7594db0d Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Tue, 6 Jun 2023 15:46:23 -0400 Subject: [PATCH 1/6] Added mongo-express for Catalog db observation --- .../docker-compose.infrastructure.override.yml | 8 ++++++++ etc/docker/docker-compose.infrastructure.yml | 15 +++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/etc/docker/docker-compose.infrastructure.override.yml b/etc/docker/docker-compose.infrastructure.override.yml index 7b9c83a2..fcb33771 100644 --- a/etc/docker/docker-compose.infrastructure.override.yml +++ b/etc/docker/docker-compose.infrastructure.override.yml @@ -14,6 +14,14 @@ services: ports: - "27017:27017" + mongo-express: + ports: + - "8081:8081" + environment: + - ME_CONFIG_MONGODB_SERVER=mongodb + - ME_CONFIG_BASICAUTH_USERNAME=admin + - ME_CONFIG_BASICAUTH_PASSWORD=admin123 + postgres-db: ports: - "5432:5432" diff --git a/etc/docker/docker-compose.infrastructure.yml b/etc/docker/docker-compose.infrastructure.yml index 3f72762f..db430970 100644 --- a/etc/docker/docker-compose.infrastructure.yml +++ b/etc/docker/docker-compose.infrastructure.yml @@ -24,6 +24,21 @@ services: retries: 10 networks: - eshoponabp-network + + mongo-express: + image: mongo-express + container_name: mongo-express + depends_on: + - mongodb + restart: unless-stopped + healthcheck: + test: wget --quiet --tries=3 --spider http://admin:admin123@mongo-express:8081 || exit 1 + interval: 30s + timeout: 10s + retries: 3 + networks: + - eshoponabp-network + redis: container_name: redis image: redis:alpine From 72f17a1fd097aa4b95619cb56e9806ee3f95feb3 Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Tue, 6 Jun 2023 15:52:24 -0400 Subject: [PATCH 2/6] CatalogService namespace fix --- .../CatalogServiceAppService.cs | 5 +---- .../DbMigrations/CatalogServiceDatabaseMigrationChecker.cs | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/services/catalog/src/EShopOnAbp.CatalogService.Application/CatalogServiceAppService.cs b/services/catalog/src/EShopOnAbp.CatalogService.Application/CatalogServiceAppService.cs index 702d075b..7c9af03e 100644 --- a/services/catalog/src/EShopOnAbp.CatalogService.Application/CatalogServiceAppService.cs +++ b/services/catalog/src/EShopOnAbp.CatalogService.Application/CatalogServiceAppService.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using EShopOnAbp.CatalogService.Localization; +using EShopOnAbp.CatalogService.Localization; using Volo.Abp.Application.Services; namespace EShopOnAbp.CatalogService diff --git a/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/DbMigrations/CatalogServiceDatabaseMigrationChecker.cs b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/DbMigrations/CatalogServiceDatabaseMigrationChecker.cs index 57be9d19..51277363 100644 --- a/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/DbMigrations/CatalogServiceDatabaseMigrationChecker.cs +++ b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/DbMigrations/CatalogServiceDatabaseMigrationChecker.cs @@ -1,6 +1,6 @@ using EShopOnAbp.CatalogService.MongoDB; -using EShopOnAbp.Shared.Hosting.Microservices.DbMigrations; using System; +using EShopOnAbp.Shared.Hosting.Microservices.DbMigrations.MongoDb; using Volo.Abp.Data; using Volo.Abp.DistributedLocking; using Volo.Abp.MultiTenancy; From f4ad2454dc3e6aa4adb68982a2dd75060e5399af Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Tue, 6 Jun 2023 15:53:47 -0400 Subject: [PATCH 3/6] OrderingService updated to use file-scoped namespaces --- ...deringServiceApplicationContractsModule.cs | 19 +++-- .../OrderingServiceRemoteServiceConsts.cs | 11 ++- .../Orders/DashboardDto.cs | 15 ++-- .../Orders/DashboardInput.cs | 9 +-- .../Orders/GetOrdersInput.cs | 9 +-- .../Permissions/OrderingServicePermissions.cs | 29 ++++---- .../OrderingServiceApplicationModule.cs | 31 ++++---- .../Localization/OrderingServiceResource.cs | 11 ++- .../OrderingServiceDomainSharedModule.cs | 47 ++++++------ .../Orders/OrderAcceptedEto.cs | 21 +++--- .../Orders/OrderItemEto.cs | 21 +++--- .../OrderingServiceDbProperties.cs | 15 ++-- .../OrderingServiceDomainModule.cs | 17 ++--- .../Orders/IOrderRepository.cs | 1 - .../PaymentRequestEventHandler.cs | 73 +++++++++---------- ...rderingServiceSettingDefinitionProvider.cs | 15 ++-- .../Settings/OrderingServiceSettings.cs | 15 ++-- .../IOrderingServiceDbContext.cs | 17 ++--- .../OrderingServiceDbContextFactory.cs | 43 ++++++----- ...ServiceDbContextModelCreatingExtensions.cs | 43 ++++++----- ...ingServiceEfCoreEntityExtensionMappings.cs | 61 ++++++++-------- ...rderingServiceEntityFrameworkCoreModule.cs | 55 +++++++------- .../Orders/EfCoreOrderRepository.cs | 1 - .../OrderingServiceHttpApiClientModule.cs | 33 ++++----- ...OrderingServiceDatabaseMigrationChecker.cs | 3 +- .../OrderingServiceController.cs | 13 ++-- .../OrderingServiceHttpApiModule.cs | 39 +++++----- 27 files changed, 320 insertions(+), 347 deletions(-) diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/OrderingServiceApplicationContractsModule.cs b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/OrderingServiceApplicationContractsModule.cs index b4b42c8f..0b48cbfa 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/OrderingServiceApplicationContractsModule.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/OrderingServiceApplicationContractsModule.cs @@ -2,15 +2,14 @@ using Volo.Abp.Modularity; using Volo.Abp.Authorization; -namespace EShopOnAbp.OrderingService +namespace EShopOnAbp.OrderingService; + +[DependsOn( + typeof(OrderingServiceDomainSharedModule), + typeof(AbpDddApplicationContractsModule), + typeof(AbpAuthorizationModule) +)] +public class OrderingServiceApplicationContractsModule : AbpModule { - [DependsOn( - typeof(OrderingServiceDomainSharedModule), - typeof(AbpDddApplicationContractsModule), - typeof(AbpAuthorizationModule) - )] - public class OrderingServiceApplicationContractsModule : AbpModule - { - } -} +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/OrderingServiceRemoteServiceConsts.cs b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/OrderingServiceRemoteServiceConsts.cs index 6259d93c..35e7f18c 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/OrderingServiceRemoteServiceConsts.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/OrderingServiceRemoteServiceConsts.cs @@ -1,7 +1,6 @@ -namespace EShopOnAbp.OrderingService +namespace EShopOnAbp.OrderingService; + +public static class OrderingServiceRemoteServiceConsts { - public static class OrderingServiceRemoteServiceConsts - { - public const string RemoteServiceName = "Ordering"; - } -} + public const string RemoteServiceName = "Ordering"; +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/DashboardDto.cs b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/DashboardDto.cs index 2d44e0ee..0696ee5d 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/DashboardDto.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/DashboardDto.cs @@ -2,12 +2,11 @@ using System.Collections.Generic; using Volo.Abp.Application.Dtos; -namespace EShopOnAbp.OrderingService.Orders +namespace EShopOnAbp.OrderingService.Orders; + +public class DashboardDto: EntityDto { - public class DashboardDto: EntityDto - { - public List TopSellings { get; set; } - public List Payments { get; set; } - public List OrderStatusDto { get; set; } - } -} + public List TopSellings { get; set; } + public List Payments { get; set; } + public List OrderStatusDto { get; set; } +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/DashboardInput.cs b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/DashboardInput.cs index 63f83b08..bb8bff2f 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/DashboardInput.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/DashboardInput.cs @@ -1,7 +1,6 @@ -namespace EShopOnAbp.OrderingService.Orders +namespace EShopOnAbp.OrderingService.Orders; + +public class DashboardInput { - public class DashboardInput - { - public string Filter { get; set; } - } + public string Filter { get; set; } } \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/GetOrdersInput.cs b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/GetOrdersInput.cs index 8be79fd0..b3b4d464 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/GetOrdersInput.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/GetOrdersInput.cs @@ -1,7 +1,6 @@ -namespace EShopOnAbp.OrderingService.Orders +namespace EShopOnAbp.OrderingService.Orders; + +public class GetOrdersInput { - public class GetOrdersInput - { - public string Filter { get; set; } - } + public string Filter { get; set; } } \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Permissions/OrderingServicePermissions.cs b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Permissions/OrderingServicePermissions.cs index 52b55b9e..9df82a46 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Permissions/OrderingServicePermissions.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Permissions/OrderingServicePermissions.cs @@ -1,22 +1,21 @@ using Volo.Abp.Reflection; -namespace EShopOnAbp.OrderingService.Permissions +namespace EShopOnAbp.OrderingService.Permissions; + +public static class OrderingServicePermissions { - public static class OrderingServicePermissions - { - public const string GroupName = "OrderingService"; + public const string GroupName = "OrderingService"; - public static class Orders - { - public const string Default = GroupName + ".Orders"; - public const string SetAsCancelled = GroupName + ".SetAsCancelled"; - public const string SetAsShipped = GroupName + ".SetAsShipped"; - public const string Dashboard = GroupName + ".Dashboard"; - } + public static class Orders + { + public const string Default = GroupName + ".Orders"; + public const string SetAsCancelled = GroupName + ".SetAsCancelled"; + public const string SetAsShipped = GroupName + ".SetAsShipped"; + public const string Dashboard = GroupName + ".Dashboard"; + } - public static string[] GetAll() - { - return ReflectionHelper.GetPublicConstantsRecursively(typeof(OrderingServicePermissions)); - } + public static string[] GetAll() + { + return ReflectionHelper.GetPublicConstantsRecursively(typeof(OrderingServicePermissions)); } } \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Application/OrderingServiceApplicationModule.cs b/services/ordering/src/EShopOnAbp.OrderingService.Application/OrderingServiceApplicationModule.cs index 47e5d2ff..0ce0520c 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.Application/OrderingServiceApplicationModule.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.Application/OrderingServiceApplicationModule.cs @@ -3,23 +3,22 @@ using Volo.Abp.AutoMapper; using Volo.Abp.Modularity; using Volo.Abp.Application; -namespace EShopOnAbp.OrderingService +namespace EShopOnAbp.OrderingService; + +[DependsOn( + typeof(OrderingServiceDomainModule), + typeof(OrderingServiceApplicationContractsModule), + typeof(AbpDddApplicationModule), + typeof(AbpAutoMapperModule) +)] +public class OrderingServiceApplicationModule : AbpModule { - [DependsOn( - typeof(OrderingServiceDomainModule), - typeof(OrderingServiceApplicationContractsModule), - typeof(AbpDddApplicationModule), - typeof(AbpAutoMapperModule) - )] - public class OrderingServiceApplicationModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) + context.Services.AddAutoMapperObjectMapper(); + Configure(options => { - context.Services.AddAutoMapperObjectMapper(); - Configure(options => - { - options.AddMaps(validate: true); - }); - } + options.AddMaps(validate: true); + }); } -} +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingServiceResource.cs b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingServiceResource.cs index cc7f7121..02853616 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingServiceResource.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingServiceResource.cs @@ -1,10 +1,9 @@ using Volo.Abp.Localization; -namespace EShopOnAbp.OrderingService.Localization +namespace EShopOnAbp.OrderingService.Localization; + +[LocalizationResourceName("OrderingService")] +public class OrderingServiceResource { - [LocalizationResourceName("OrderingService")] - public class OrderingServiceResource - { - } -} +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/OrderingServiceDomainSharedModule.cs b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/OrderingServiceDomainSharedModule.cs index f3dce386..d0edae99 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/OrderingServiceDomainSharedModule.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/OrderingServiceDomainSharedModule.cs @@ -7,33 +7,32 @@ using Volo.Abp.Validation.Localization; using Volo.Abp.VirtualFileSystem; using EShopOnAbp.PaymentService; -namespace EShopOnAbp.OrderingService +namespace EShopOnAbp.OrderingService; + +[DependsOn( + typeof(AbpValidationModule), + typeof(PaymentServiceDomainSharedModule) +)] +public class OrderingServiceDomainSharedModule : AbpModule { - [DependsOn( - typeof(AbpValidationModule), - typeof(PaymentServiceDomainSharedModule) - )] - public class OrderingServiceDomainSharedModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) + Configure(options => { - Configure(options => - { - options.FileSets.AddEmbedded(); - }); + options.FileSets.AddEmbedded(); + }); - Configure(options => - { - options.Resources - .Add("en") - .AddBaseTypes(typeof(AbpValidationResource)) - .AddVirtualJson("/Localization/OrderingService"); - }); + Configure(options => + { + options.Resources + .Add("en") + .AddBaseTypes(typeof(AbpValidationResource)) + .AddVirtualJson("/Localization/OrderingService"); + }); - Configure(options => - { - options.MapCodeNamespace("OrderingService", typeof(OrderingServiceResource)); - }); - } + Configure(options => + { + options.MapCodeNamespace("OrderingService", typeof(OrderingServiceResource)); + }); } -} +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Orders/OrderAcceptedEto.cs b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Orders/OrderAcceptedEto.cs index f88d2f57..d84d1742 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Orders/OrderAcceptedEto.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Orders/OrderAcceptedEto.cs @@ -3,15 +3,14 @@ using System.Collections.Generic; using Volo.Abp.Domain.Entities.Events.Distributed; using Volo.Abp.EventBus; -namespace EShopOnAbp.OrderingService.Orders +namespace EShopOnAbp.OrderingService.Orders; + +[Serializable] +[EventName("EShopOnAbp.Order.Accepted")] +public class OrderAcceptedEto : EtoBase { - [Serializable] - [EventName("EShopOnAbp.Order.Accepted")] - public class OrderAcceptedEto : EtoBase - { - public Guid OrderId { get; set; } - public string PaymentStatus { get; set; } - public BuyerEto Buyer { get; set; } - public List Items { get; set; } - } -} + public Guid OrderId { get; set; } + public string PaymentStatus { get; set; } + public BuyerEto Buyer { get; set; } + public List Items { get; set; } +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Orders/OrderItemEto.cs b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Orders/OrderItemEto.cs index 83bf27fc..3f1c98cc 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Orders/OrderItemEto.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Orders/OrderItemEto.cs @@ -1,16 +1,15 @@ using System; using Volo.Abp.Domain.Entities.Events.Distributed; -namespace EShopOnAbp.OrderingService.Orders +namespace EShopOnAbp.OrderingService.Orders; + +public class OrderItemEto : EtoBase { - public class OrderItemEto : EtoBase - { - public Guid ProductId { get; set; } - public string ProductCode { get; set; } - public string ProductName { get; set; } - public string PictureUrl { get; set; } - public decimal UnitPrice { get; set; } - public decimal Discount { get; set; } - public int Units { get; set; } - } + public Guid ProductId { get; set; } + public string ProductCode { get; set; } + public string ProductName { get; set; } + public string PictureUrl { get; set; } + public decimal UnitPrice { get; set; } + public decimal Discount { get; set; } + public int Units { get; set; } } \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain/OrderingServiceDbProperties.cs b/services/ordering/src/EShopOnAbp.OrderingService.Domain/OrderingServiceDbProperties.cs index 61451e62..28220325 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.Domain/OrderingServiceDbProperties.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain/OrderingServiceDbProperties.cs @@ -1,11 +1,10 @@ -namespace EShopOnAbp.OrderingService +namespace EShopOnAbp.OrderingService; + +public static class OrderingServiceDbProperties { - public static class OrderingServiceDbProperties - { - public static string DbTablePrefix { get; set; } = ""; + public static string DbTablePrefix { get; set; } = ""; - public static string DbSchema { get; set; } + public static string DbSchema { get; set; } - public const string ConnectionStringName = "OrderingService"; - } -} + public const string ConnectionStringName = "OrderingService"; +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain/OrderingServiceDomainModule.cs b/services/ordering/src/EShopOnAbp.OrderingService.Domain/OrderingServiceDomainModule.cs index c2634e07..9bfb6ca6 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.Domain/OrderingServiceDomainModule.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain/OrderingServiceDomainModule.cs @@ -1,14 +1,13 @@ using Volo.Abp.Domain; using Volo.Abp.Modularity; -namespace EShopOnAbp.OrderingService +namespace EShopOnAbp.OrderingService; + +[DependsOn( + typeof(AbpDddDomainModule), + typeof(OrderingServiceDomainSharedModule) +)] +public class OrderingServiceDomainModule : AbpModule { - [DependsOn( - typeof(AbpDddDomainModule), - typeof(OrderingServiceDomainSharedModule) - )] - public class OrderingServiceDomainModule : AbpModule - { - } -} +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/IOrderRepository.cs b/services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/IOrderRepository.cs index 97e3fd77..8f2534b7 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/IOrderRepository.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/IOrderRepository.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; using Volo.Abp.Domain.Repositories; diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain/PaymentRequests/PaymentRequestEventHandler.cs b/services/ordering/src/EShopOnAbp.OrderingService.Domain/PaymentRequests/PaymentRequestEventHandler.cs index a72f14e3..4b1fa6e6 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.Domain/PaymentRequests/PaymentRequestEventHandler.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain/PaymentRequests/PaymentRequestEventHandler.cs @@ -7,52 +7,51 @@ using Volo.Abp; using Volo.Abp.DependencyInjection; using Volo.Abp.EventBus.Distributed; -namespace EShopOnAbp.OrderingService.PaymentRequests +namespace EShopOnAbp.OrderingService.PaymentRequests; + +public class PaymentRequestEventHandler : IDistributedEventHandler, + ITransientDependency { - public class PaymentRequestEventHandler : IDistributedEventHandler, - ITransientDependency + private readonly IDistributedEventBus _eventBus; + private readonly OrderManager _orderManager; + + public PaymentRequestEventHandler(IDistributedEventBus eventBus, OrderManager orderManager) { - private readonly IDistributedEventBus _eventBus; - private readonly OrderManager _orderManager; + _eventBus = eventBus; + _orderManager = orderManager; + } - public PaymentRequestEventHandler(IDistributedEventBus eventBus, OrderManager orderManager) + public async Task HandleEventAsync(PaymentRequestCompletedEto eventData) + { + if (!Guid.TryParse(eventData.OrderId, out var orderId)) { - _eventBus = eventBus; - _orderManager = orderManager; + throw new BusinessException(OrderingServiceErrorCodes.OrderIdIdNotGuid); } - public async Task HandleEventAsync(PaymentRequestCompletedEto eventData) - { - if (!Guid.TryParse(eventData.OrderId, out var orderId)) - { - throw new BusinessException(OrderingServiceErrorCodes.OrderIdIdNotGuid); - } - - var acceptedOrder = await _orderManager.AcceptOrderAsync( - orderId, eventData.PaymentRequestId, eventData.State.ToString() - ); + var acceptedOrder = await _orderManager.AcceptOrderAsync( + orderId, eventData.PaymentRequestId, eventData.State.ToString() + ); - await _eventBus.PublishAsync(new OrderAcceptedEto + await _eventBus.PublishAsync(new OrderAcceptedEto + { + Items = eventData.Products.Select(MapProductToOrderItem).ToList(), + PaymentStatus = acceptedOrder.PaymentStatus, + Buyer = new BuyerEto { - Items = eventData.Products.Select(MapProductToOrderItem).ToList(), - PaymentStatus = acceptedOrder.PaymentStatus, - Buyer = new BuyerEto - { - BuyerId = acceptedOrder.Buyer.Id, - BuyerEmail = acceptedOrder.Buyer.Email, - BuyerName = acceptedOrder.Buyer.Name - }, - OrderId = acceptedOrder.Id - }); - } + BuyerId = acceptedOrder.Buyer.Id, + BuyerEmail = acceptedOrder.Buyer.Email, + BuyerName = acceptedOrder.Buyer.Name + }, + OrderId = acceptedOrder.Id + }); + } - private static OrderItemEto MapProductToOrderItem(PaymentRequestProductEto arg) + private static OrderItemEto MapProductToOrderItem(PaymentRequestProductEto arg) + { + return new OrderItemEto { - return new OrderItemEto - { - Units = arg.Quantity, - ProductId = Guid.Parse(arg.ReferenceId) - }; - } + Units = arg.Quantity, + ProductId = Guid.Parse(arg.ReferenceId) + }; } } \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain/Settings/OrderingServiceSettingDefinitionProvider.cs b/services/ordering/src/EShopOnAbp.OrderingService.Domain/Settings/OrderingServiceSettingDefinitionProvider.cs index ac0284a3..480e93fd 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.Domain/Settings/OrderingServiceSettingDefinitionProvider.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain/Settings/OrderingServiceSettingDefinitionProvider.cs @@ -1,14 +1,13 @@ using Volo.Abp.Settings; -namespace EShopOnAbp.OrderingService.Settings +namespace EShopOnAbp.OrderingService.Settings; + +public class OrderingServiceSettingDefinitionProvider : SettingDefinitionProvider { - public class OrderingServiceSettingDefinitionProvider : SettingDefinitionProvider + public override void Define(ISettingDefinitionContext context) { - public override void Define(ISettingDefinitionContext context) - { - /* Define module settings here. - * Use names from OrderingServiceSettings class. - */ - } + /* Define module settings here. + * Use names from OrderingServiceSettings class. + */ } } \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain/Settings/OrderingServiceSettings.cs b/services/ordering/src/EShopOnAbp.OrderingService.Domain/Settings/OrderingServiceSettings.cs index f1346cc9..24a82b68 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.Domain/Settings/OrderingServiceSettings.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain/Settings/OrderingServiceSettings.cs @@ -1,11 +1,10 @@ -namespace EShopOnAbp.OrderingService.Settings +namespace EShopOnAbp.OrderingService.Settings; + +public static class OrderingServiceSettings { - public static class OrderingServiceSettings - { - public const string GroupName = "OrderingService"; + public const string GroupName = "OrderingService"; - /* Add constants for setting names. Example: - * public const string MySettingName = GroupName + ".MySettingName"; - */ - } + /* Add constants for setting names. Example: + * public const string MySettingName = GroupName + ".MySettingName"; + */ } \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/IOrderingServiceDbContext.cs b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/IOrderingServiceDbContext.cs index 7589800b..2be632dc 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/IOrderingServiceDbContext.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/IOrderingServiceDbContext.cs @@ -3,14 +3,13 @@ using Microsoft.EntityFrameworkCore; using Volo.Abp.Data; using Volo.Abp.EntityFrameworkCore; -namespace EShopOnAbp.OrderingService.EntityFrameworkCore +namespace EShopOnAbp.OrderingService.EntityFrameworkCore; + +[ConnectionStringName(OrderingServiceDbProperties.ConnectionStringName)] +public interface IOrderingServiceDbContext : IEfCoreDbContext { - [ConnectionStringName(OrderingServiceDbProperties.ConnectionStringName)] - public interface IOrderingServiceDbContext : IEfCoreDbContext - { - /* Add DbSet for each Aggregate Root here. Example: - * DbSet Questions { get; } - */ - DbSet Orders { get; } - } + /* Add DbSet for each Aggregate Root here. Example: + * DbSet Questions { get; } + */ + DbSet Orders { get; } } \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceDbContextFactory.cs b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceDbContextFactory.cs index 0486119a..bf407267 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceDbContextFactory.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceDbContextFactory.cs @@ -4,39 +4,38 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; using Microsoft.Extensions.Configuration; -namespace EShopOnAbp.OrderingService.EntityFrameworkCore +namespace EShopOnAbp.OrderingService.EntityFrameworkCore; + +/* This class is needed for EF Core console commands + * (like Add-Migration and Update-Database commands) */ +public class OrderingServiceDbContextFactory : IDesignTimeDbContextFactory { - /* This class is needed for EF Core console commands - * (like Add-Migration and Update-Database commands) */ - public class OrderingServiceDbContextFactory : IDesignTimeDbContextFactory + public OrderingServiceDbContext CreateDbContext(string[] args) { - public OrderingServiceDbContext CreateDbContext(string[] args) - { - OrderingServiceEfCoreEntityExtensionMappings.Configure(); + OrderingServiceEfCoreEntityExtensionMappings.Configure(); - var configuration = BuildConfiguration(); + var configuration = BuildConfiguration(); - var builder = new DbContextOptionsBuilder() - .UseNpgsql( + var builder = new DbContextOptionsBuilder() + .UseNpgsql( configuration.GetConnectionString(OrderingServiceDbProperties.ConnectionStringName), b => { b.MigrationsHistoryTable("__OrderingService_Migrations"); }); - // https://www.npgsql.org/efcore/release-notes/6.0.html#opting-out-of-the-new-timestamp-mapping-logic - AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); + // https://www.npgsql.org/efcore/release-notes/6.0.html#opting-out-of-the-new-timestamp-mapping-logic + AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); - return new OrderingServiceDbContext(builder.Options); - } + return new OrderingServiceDbContext(builder.Options); + } - private static IConfigurationRoot BuildConfiguration() - { - var builder = new ConfigurationBuilder() - .SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "../EShopOnAbp.OrderingService.HttpApi.Host/")) - .AddJsonFile("appsettings.json", optional: false); + private static IConfigurationRoot BuildConfiguration() + { + var builder = new ConfigurationBuilder() + .SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "../EShopOnAbp.OrderingService.HttpApi.Host/")) + .AddJsonFile("appsettings.json", optional: false); - return builder.Build(); - } + return builder.Build(); } -} +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceDbContextModelCreatingExtensions.cs b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceDbContextModelCreatingExtensions.cs index 50e1b749..af3f19ae 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceDbContextModelCreatingExtensions.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceDbContextModelCreatingExtensions.cs @@ -1,34 +1,33 @@ using Microsoft.EntityFrameworkCore; using Volo.Abp; -namespace EShopOnAbp.OrderingService.EntityFrameworkCore +namespace EShopOnAbp.OrderingService.EntityFrameworkCore; + +public static class OrderingServiceDbContextModelCreatingExtensions { - public static class OrderingServiceDbContextModelCreatingExtensions + public static void ConfigureOrderingService( + this ModelBuilder builder) { - public static void ConfigureOrderingService( - this ModelBuilder builder) - { - Check.NotNull(builder, nameof(builder)); + Check.NotNull(builder, nameof(builder)); - /* Configure all entities here. Example: + /* Configure all entities here. Example: - builder.Entity(b => - { - //Configure table & schema name - b.ToTable(OrderingServiceDbProperties.DbTablePrefix + "Questions", OrderingServiceDbProperties.DbSchema); + builder.Entity(b => + { + //Configure table & schema name + b.ToTable(OrderingServiceDbProperties.DbTablePrefix + "Questions", OrderingServiceDbProperties.DbSchema); - b.ConfigureByConvention(); + b.ConfigureByConvention(); - //Properties - b.Property(q => q.Title).IsRequired().HasMaxLength(QuestionConsts.MaxTitleLength); + //Properties + b.Property(q => q.Title).IsRequired().HasMaxLength(QuestionConsts.MaxTitleLength); - //Relations - b.HasMany(question => question.Tags).WithOne().HasForeignKey(qt => qt.QuestionId); + //Relations + b.HasMany(question => question.Tags).WithOne().HasForeignKey(qt => qt.QuestionId); - //Indexes - b.HasIndex(q => q.CreationTime); - }); - */ - } + //Indexes + b.HasIndex(q => q.CreationTime); + }); + */ } -} +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceEfCoreEntityExtensionMappings.cs b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceEfCoreEntityExtensionMappings.cs index be594b2e..d0db29d2 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceEfCoreEntityExtensionMappings.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceEfCoreEntityExtensionMappings.cs @@ -1,39 +1,38 @@ using Volo.Abp.Threading; -namespace EShopOnAbp.OrderingService.EntityFrameworkCore +namespace EShopOnAbp.OrderingService.EntityFrameworkCore; + +public static class OrderingServiceEfCoreEntityExtensionMappings { - public static class OrderingServiceEfCoreEntityExtensionMappings - { - private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); + private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); - public static void Configure() + public static void Configure() + { + OneTimeRunner.Run(() => { - OneTimeRunner.Run(() => - { - /* You can configure extra properties for the - * entities defined in the modules used by your application. - * - * This class can be used to map these extra properties to table fields in the database. - * - * USE THIS CLASS ONLY TO CONFIGURE EF CORE RELATED MAPPING. - * USE OrderingServiceModuleExtensionConfigurator CLASS (in the Domain.Shared project) - * FOR A HIGH LEVEL API TO DEFINE EXTRA PROPERTIES TO ENTITIES OF THE USED MODULES - * - * Example: Map a property to a table field: + /* You can configure extra properties for the + * entities defined in the modules used by your application. + * + * This class can be used to map these extra properties to table fields in the database. + * + * USE THIS CLASS ONLY TO CONFIGURE EF CORE RELATED MAPPING. + * USE OrderingServiceModuleExtensionConfigurator CLASS (in the Domain.Shared project) + * FOR A HIGH LEVEL API TO DEFINE EXTRA PROPERTIES TO ENTITIES OF THE USED MODULES + * + * Example: Map a property to a table field: - ObjectExtensionManager.Instance - .MapEfCoreProperty( - "MyProperty", - (entityBuilder, propertyBuilder) => - { - propertyBuilder.HasMaxLength(128); - } - ); + ObjectExtensionManager.Instance + .MapEfCoreProperty( + "MyProperty", + (entityBuilder, propertyBuilder) => + { + propertyBuilder.HasMaxLength(128); + } + ); - * See the documentation for more: - * https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Extending-Entities - */ - }); - } + * See the documentation for more: + * https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Extending-Entities + */ + }); } -} +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceEntityFrameworkCoreModule.cs b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceEntityFrameworkCoreModule.cs index ec35b6d1..65c181e0 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceEntityFrameworkCoreModule.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceEntityFrameworkCoreModule.cs @@ -4,40 +4,39 @@ using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore.PostgreSql; using Volo.Abp.Modularity; -namespace EShopOnAbp.OrderingService.EntityFrameworkCore +namespace EShopOnAbp.OrderingService.EntityFrameworkCore; + +[DependsOn( + typeof(OrderingServiceDomainModule), + typeof(AbpEntityFrameworkCorePostgreSqlModule) +)] +public class OrderingServiceEntityFrameworkCoreModule : AbpModule { - [DependsOn( - typeof(OrderingServiceDomainModule), - typeof(AbpEntityFrameworkCorePostgreSqlModule) - )] - public class OrderingServiceEntityFrameworkCoreModule : AbpModule + public override void PreConfigureServices(ServiceConfigurationContext context) { - public override void PreConfigureServices(ServiceConfigurationContext context) - { - OrderingServiceEfCoreEntityExtensionMappings.Configure(); - } + OrderingServiceEfCoreEntityExtensionMappings.Configure(); + } - public override void ConfigureServices(ServiceConfigurationContext context) + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddAbpDbContext(options => { - context.Services.AddAbpDbContext(options => - { - /* Remove "includeAllEntities: true" to create - * default repositories only for aggregate roots */ - options.AddDefaultRepositories(includeAllEntities: true); - }); + /* Remove "includeAllEntities: true" to create + * default repositories only for aggregate roots */ + options.AddDefaultRepositories(includeAllEntities: true); + }); - // https://www.npgsql.org/efcore/release-notes/6.0.html#opting-out-of-the-new-timestamp-mapping-logic - AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); + // https://www.npgsql.org/efcore/release-notes/6.0.html#opting-out-of-the-new-timestamp-mapping-logic + AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); - Configure(options => + Configure(options => + { + /* The main point to change your DBMS. + * See also OrderingServiceMigrationsDbContextFactory for EF Core tooling. */ + options.UseNpgsql(b => { - /* The main point to change your DBMS. - * See also OrderingServiceMigrationsDbContextFactory for EF Core tooling. */ - options.UseNpgsql(b => - { - b.MigrationsHistoryTable("__OrderingService_Migrations"); - }); + b.MigrationsHistoryTable("__OrderingService_Migrations"); }); - } + }); } -} +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Orders/EfCoreOrderRepository.cs b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Orders/EfCoreOrderRepository.cs index f84e01d2..c6d39e86 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Orders/EfCoreOrderRepository.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Orders/EfCoreOrderRepository.cs @@ -3,7 +3,6 @@ using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.Linq; -using System.Linq.Dynamic.Core; using System.Threading; using System.Threading.Tasks; using Volo.Abp.Domain.Entities; diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/OrderingServiceHttpApiClientModule.cs b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/OrderingServiceHttpApiClientModule.cs index 762bb7f6..d4a92197 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/OrderingServiceHttpApiClientModule.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/OrderingServiceHttpApiClientModule.cs @@ -3,25 +3,24 @@ using Volo.Abp.Http.Client; using Volo.Abp.Modularity; using Volo.Abp.VirtualFileSystem; -namespace EShopOnAbp.OrderingService +namespace EShopOnAbp.OrderingService; + +[DependsOn( + typeof(OrderingServiceApplicationContractsModule), + typeof(AbpHttpClientModule))] +public class OrderingServiceHttpApiClientModule : AbpModule { - [DependsOn( - typeof(OrderingServiceApplicationContractsModule), - typeof(AbpHttpClientModule))] - public class OrderingServiceHttpApiClientModule : AbpModule + public const string RemoteServiceName = "Ordering"; + public override void ConfigureServices(ServiceConfigurationContext context) { - public const string RemoteServiceName = "Ordering"; - public override void ConfigureServices(ServiceConfigurationContext context) - { - context.Services.AddStaticHttpClientProxies( - typeof(OrderingServiceApplicationContractsModule).Assembly, - RemoteServiceName - ); + context.Services.AddStaticHttpClientProxies( + typeof(OrderingServiceApplicationContractsModule).Assembly, + RemoteServiceName + ); - Configure(options => - { - options.FileSets.AddEmbedded(); - }); - } + Configure(options => + { + options.FileSets.AddEmbedded(); + }); } } \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/DbMigrations/OrderingServiceDatabaseMigrationChecker.cs b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/DbMigrations/OrderingServiceDatabaseMigrationChecker.cs index b910af00..33d1bc74 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/DbMigrations/OrderingServiceDatabaseMigrationChecker.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/DbMigrations/OrderingServiceDatabaseMigrationChecker.cs @@ -8,8 +8,7 @@ using Volo.Abp.DistributedLocking; namespace EShopOnAbp.OrderingService.DbMigrations; -public class OrderingServiceDatabaseMigrationChecker - : PendingEfCoreMigrationsChecker +public class OrderingServiceDatabaseMigrationChecker : PendingEfCoreMigrationsChecker { public OrderingServiceDatabaseMigrationChecker( IUnitOfWorkManager unitOfWorkManager, diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi/OrderingServiceController.cs b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi/OrderingServiceController.cs index 2e48136a..8c6a105d 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi/OrderingServiceController.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi/OrderingServiceController.cs @@ -1,13 +1,12 @@ using EShopOnAbp.OrderingService.Localization; using Volo.Abp.AspNetCore.Mvc; -namespace EShopOnAbp.OrderingService +namespace EShopOnAbp.OrderingService; + +public abstract class OrderingServiceController : AbpControllerBase { - public abstract class OrderingServiceController : AbpControllerBase + protected OrderingServiceController() { - protected OrderingServiceController() - { - LocalizationResource = typeof(OrderingServiceResource); - } + LocalizationResource = typeof(OrderingServiceResource); } -} +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi/OrderingServiceHttpApiModule.cs b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi/OrderingServiceHttpApiModule.cs index d5ac59bc..30c59ad1 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi/OrderingServiceHttpApiModule.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi/OrderingServiceHttpApiModule.cs @@ -5,29 +5,28 @@ using Volo.Abp.Localization; using Volo.Abp.Modularity; using Microsoft.Extensions.DependencyInjection; -namespace EShopOnAbp.OrderingService +namespace EShopOnAbp.OrderingService; + +[DependsOn( + typeof(OrderingServiceApplicationContractsModule), + typeof(AbpAspNetCoreMvcModule))] +public class OrderingServiceHttpApiModule : AbpModule { - [DependsOn( - typeof(OrderingServiceApplicationContractsModule), - typeof(AbpAspNetCoreMvcModule))] - public class OrderingServiceHttpApiModule : AbpModule + public override void PreConfigureServices(ServiceConfigurationContext context) { - public override void PreConfigureServices(ServiceConfigurationContext context) + PreConfigure(mvcBuilder => { - PreConfigure(mvcBuilder => - { - mvcBuilder.AddApplicationPartIfNotExists(typeof(OrderingServiceHttpApiModule).Assembly); - }); - } + mvcBuilder.AddApplicationPartIfNotExists(typeof(OrderingServiceHttpApiModule).Assembly); + }); + } - public override void ConfigureServices(ServiceConfigurationContext context) + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => { - Configure(options => - { - options.Resources - .Get() - .AddBaseTypes(typeof(AbpUiResource)); - }); - } + options.Resources + .Get() + .AddBaseTypes(typeof(AbpUiResource)); + }); } -} +} \ No newline at end of file From 1590f819d2c4903f705d3db2fb0f0da672ca44c2 Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Tue, 6 Jun 2023 15:54:20 -0400 Subject: [PATCH 4/6] PaymentService updated to use file-scoped namespaces and namespace fix --- .../PaymentRequests/PaymentCompletedEto.cs | 13 ++++---- .../PaymentRequestCreationDto.cs | 31 +++++++++---------- .../PaymentRequests/PaymentRequestDto.cs | 29 +++++++++-------- .../PaymentRequestProductCreationDto.cs | 29 +++++++++-------- .../PaymentRequestProductDto.cs | 21 ++++++------- .../PaymentRequests/PaymentRequestStartDto.cs | 19 ++++++------ .../PaymentRequestStartResultDto.cs | 11 +++---- .../PaymentServiceConsts.cs | 9 +++--- .../EfCorePaymentRequestRepository.cs | 1 - .../PaymentServiceDatabaseMigrationChecker.cs | 3 +- .../PendingMongoDbMigrationsChecker.cs | 8 ++--- 11 files changed, 82 insertions(+), 92 deletions(-) diff --git a/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentCompletedEto.cs b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentCompletedEto.cs index dd872e5b..aefc8b46 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentCompletedEto.cs +++ b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentCompletedEto.cs @@ -1,11 +1,10 @@ using Volo.Abp.Domain.Entities.Events.Distributed; using Volo.Abp.EventBus; -namespace EShopOnAbp.PaymentService.PaymentRequests +namespace EShopOnAbp.PaymentService.PaymentRequests; + +[EventName("EShopOnAbp.Payment.Completed")] +public class PaymentCompletedEto : EtoBase { - [EventName("EShopOnAbp.Payment.Completed")] - public class PaymentCompletedEto : EtoBase - { - public PaymentRequestDto PaymentRequest { get; set; } - } -} + public PaymentRequestDto PaymentRequest { get; set; } +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestCreationDto.cs b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestCreationDto.cs index 5584c680..f589e9f5 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestCreationDto.cs +++ b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestCreationDto.cs @@ -2,24 +2,23 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -namespace EShopOnAbp.PaymentService.PaymentRequests +namespace EShopOnAbp.PaymentService.PaymentRequests; + +[Serializable] +public class PaymentRequestCreationDto { - [Serializable] - public class PaymentRequestCreationDto - { - [Required] - [MaxLength(PaymentRequestConsts.MaxCurrencyLength)] - public string Currency { get; set; } + [Required] + [MaxLength(PaymentRequestConsts.MaxCurrencyLength)] + public string Currency { get; set; } - [Required] - [MinLength(PaymentRequestConsts.MinOrderIdLength)] - [MaxLength(PaymentRequestConsts.MaxOrderIdLength)] - public string OrderId { get; set; } + [Required] + [MinLength(PaymentRequestConsts.MinOrderIdLength)] + [MaxLength(PaymentRequestConsts.MaxOrderIdLength)] + public string OrderId { get; set; } - [Required] - public int OrderNo { get; set; } + [Required] + public int OrderNo { get; set; } - public string BuyerId { get; set; } - public List Products { get; set; } - } + public string BuyerId { get; set; } + public List Products { get; set; } } \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestDto.cs b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestDto.cs index 40631e8f..01cc0385 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestDto.cs +++ b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestDto.cs @@ -3,25 +3,24 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using Volo.Abp.Application.Dtos; -namespace EShopOnAbp.PaymentService.PaymentRequests +namespace EShopOnAbp.PaymentService.PaymentRequests; + +[Serializable] +public class PaymentRequestDto : CreationAuditedEntityDto { - [Serializable] - public class PaymentRequestDto : CreationAuditedEntityDto - { - [Required] - [MaxLength(PaymentRequestConsts.MaxCurrencyLength)] - public string Currency { get; set; } + [Required] + [MaxLength(PaymentRequestConsts.MaxCurrencyLength)] + public string Currency { get; set; } - public string OrderId { get; set; } + public string OrderId { get; set; } - public int OrderNo {get;set;} + public int OrderNo {get;set;} - public string BuyerId { get; set; } + public string BuyerId { get; set; } - public bool IsDeleted { get; set; } + public bool IsDeleted { get; set; } - public PaymentRequestState State { get; set; } + public PaymentRequestState State { get; set; } - public List Products { get; set; } - } -} + public List Products { get; set; } +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestProductCreationDto.cs b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestProductCreationDto.cs index 51ded8cf..8783a9d0 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestProductCreationDto.cs +++ b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestProductCreationDto.cs @@ -1,22 +1,21 @@ using System; using System.ComponentModel.DataAnnotations; -namespace EShopOnAbp.PaymentService.PaymentRequests +namespace EShopOnAbp.PaymentService.PaymentRequests; + +[Serializable] +public class PaymentRequestProductCreationDto { - [Serializable] - public class PaymentRequestProductCreationDto - { - public string ReferenceId { get; set; } + public string ReferenceId { get; set; } - [Required] - [MaxLength(PaymentRequestConsts.MaxCodeLength)] - public string Code { get; set; } + [Required] + [MaxLength(PaymentRequestConsts.MaxCodeLength)] + public string Code { get; set; } - [Required] - [MaxLength(PaymentRequestConsts.MaxNameLength)] - public string Name { get; set; } - public decimal UnitPrice { get; set; } - public int Quantity { get; set; } - public decimal TotalPrice { get; set; } - } + [Required] + [MaxLength(PaymentRequestConsts.MaxNameLength)] + public string Name { get; set; } + public decimal UnitPrice { get; set; } + public int Quantity { get; set; } + public decimal TotalPrice { get; set; } } \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestProductDto.cs b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestProductDto.cs index 4246e772..062ac0e1 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestProductDto.cs +++ b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestProductDto.cs @@ -1,23 +1,22 @@ using System; using Volo.Abp.Application.Dtos; -namespace EShopOnAbp.PaymentService.PaymentRequests +namespace EShopOnAbp.PaymentService.PaymentRequests; + +public class PaymentRequestProductDto : EntityDto { - public class PaymentRequestProductDto : EntityDto - { - public Guid PaymentRequestId { get; set; } + public Guid PaymentRequestId { get; set; } - public string ReferenceId { get; set; } + public string ReferenceId { get; set; } - public string Code { get; set; } + public string Code { get; set; } - public string Name { get; set; } + public string Name { get; set; } - public decimal UnitPrice { get; set; } + public decimal UnitPrice { get; set; } - public int Quantity { get; set; } + public int Quantity { get; set; } - public decimal TotalPrice { get; set; } + public decimal TotalPrice { get; set; } - } } \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestStartDto.cs b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestStartDto.cs index d5b06af4..e1c691f4 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestStartDto.cs +++ b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestStartDto.cs @@ -1,17 +1,16 @@ using System; using System.ComponentModel.DataAnnotations; -namespace EShopOnAbp.PaymentService.PaymentRequests +namespace EShopOnAbp.PaymentService.PaymentRequests; + +[Serializable] +public class PaymentRequestStartDto { - [Serializable] - public class PaymentRequestStartDto - { - public int PaymentTypeId { get; set; } - public Guid PaymentRequestId { get; set; } + public int PaymentTypeId { get; set; } + public Guid PaymentRequestId { get; set; } - [Required] - public string ReturnUrl { get; set; } + [Required] + public string ReturnUrl { get; set; } - public string CancelUrl { get; set; } - } + public string CancelUrl { get; set; } } \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestStartResultDto.cs b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestStartResultDto.cs index faae6889..a2bba62a 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestStartResultDto.cs +++ b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestStartResultDto.cs @@ -1,10 +1,9 @@ using System; -namespace EShopOnAbp.PaymentService.PaymentRequests +namespace EShopOnAbp.PaymentService.PaymentRequests; + +[Serializable] +public class PaymentRequestStartResultDto { - [Serializable] - public class PaymentRequestStartResultDto - { - public string CheckoutLink { get; set; } - } + public string CheckoutLink { get; set; } } \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentServiceConsts.cs b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentServiceConsts.cs index 6bfa585d..362dc6ed 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentServiceConsts.cs +++ b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentServiceConsts.cs @@ -1,6 +1,5 @@ -namespace EShopOnAbp.PaymentService +namespace EShopOnAbp.PaymentService; + +public static class PaymentServiceConsts { - public static class PaymentServiceConsts - { - } -} +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/PaymentRequests/EfCorePaymentRequestRepository.cs b/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/PaymentRequests/EfCorePaymentRequestRepository.cs index 8d5cffa7..35df6935 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/PaymentRequests/EfCorePaymentRequestRepository.cs +++ b/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/PaymentRequests/EfCorePaymentRequestRepository.cs @@ -3,7 +3,6 @@ using Microsoft.EntityFrameworkCore; using System; using System.Linq; using System.Threading.Tasks; -using Volo.Abp.DependencyInjection; using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; diff --git a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/DbMigrations/PaymentServiceDatabaseMigrationChecker.cs b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/DbMigrations/PaymentServiceDatabaseMigrationChecker.cs index 5551fb38..ddca32ec 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/DbMigrations/PaymentServiceDatabaseMigrationChecker.cs +++ b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/DbMigrations/PaymentServiceDatabaseMigrationChecker.cs @@ -8,8 +8,7 @@ using Volo.Abp.DistributedLocking; namespace EShopOnAbp.PaymentService.DbMigrations; -public class PaymentServiceDatabaseMigrationChecker - : PendingEfCoreMigrationsChecker +public class PaymentServiceDatabaseMigrationChecker : PendingEfCoreMigrationsChecker { public PaymentServiceDatabaseMigrationChecker( IUnitOfWorkManager unitOfWorkManager, diff --git a/shared/EShopOnAbp.Shared.Hosting.Microservices/DbMigrations/MongoDb/PendingMongoDbMigrationsChecker.cs b/shared/EShopOnAbp.Shared.Hosting.Microservices/DbMigrations/MongoDb/PendingMongoDbMigrationsChecker.cs index ed8cb227..6a5fccf7 100644 --- a/shared/EShopOnAbp.Shared.Hosting.Microservices/DbMigrations/MongoDb/PendingMongoDbMigrationsChecker.cs +++ b/shared/EShopOnAbp.Shared.Hosting.Microservices/DbMigrations/MongoDb/PendingMongoDbMigrationsChecker.cs @@ -1,15 +1,15 @@ -using Microsoft.Extensions.DependencyInjection; +using System; +using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; using MongoDB.Driver; using Serilog; -using System; -using System.Threading.Tasks; using Volo.Abp.Data; using Volo.Abp.DistributedLocking; using Volo.Abp.MongoDB; using Volo.Abp.MultiTenancy; using Volo.Abp.Uow; -namespace EShopOnAbp.Shared.Hosting.Microservices.DbMigrations; +namespace EShopOnAbp.Shared.Hosting.Microservices.DbMigrations.MongoDb; public class PendingMongoDbMigrationsChecker : PendingMigrationsCheckerBase where TDbContext : AbpMongoDbContext From 073fecb7e946790b7702ffd375798e930856b2b6 Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Tue, 6 Jun 2023 16:00:57 -0400 Subject: [PATCH 5/6] BasketService updated to use file-scoped namespaces --- .../Localization/BasketServiceResource.cs | 9 +++--- .../Orders/OrderPlacedEventHandler.cs | 29 +++++++++---------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/services/basket/src/EShopOnAbp.BasketService.Contracts/Localization/BasketServiceResource.cs b/services/basket/src/EShopOnAbp.BasketService.Contracts/Localization/BasketServiceResource.cs index 07aca7a0..3bc4119d 100644 --- a/services/basket/src/EShopOnAbp.BasketService.Contracts/Localization/BasketServiceResource.cs +++ b/services/basket/src/EShopOnAbp.BasketService.Contracts/Localization/BasketServiceResource.cs @@ -1,10 +1,9 @@ using Volo.Abp.Localization; -namespace EShopOnAbp.BasketService.Localization +namespace EShopOnAbp.BasketService.Localization; + +[LocalizationResourceName("BasketService")] +public class BasketServiceResource { - [LocalizationResourceName("BasketService")] - public class BasketServiceResource - { - } } \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Entities/Orders/OrderPlacedEventHandler.cs b/services/basket/src/EShopOnAbp.BasketService/Entities/Orders/OrderPlacedEventHandler.cs index 0716d8fd..26ecef37 100644 --- a/services/basket/src/EShopOnAbp.BasketService/Entities/Orders/OrderPlacedEventHandler.cs +++ b/services/basket/src/EShopOnAbp.BasketService/Entities/Orders/OrderPlacedEventHandler.cs @@ -3,23 +3,22 @@ using Volo.Abp.DependencyInjection; using Volo.Abp.EventBus.Distributed; using Volo.Abp.Uow; -namespace EShopOnAbp.BasketService.Entities.Orders +namespace EShopOnAbp.BasketService.Entities.Orders; + +public class OrderPlacedEventHandler : IDistributedEventHandler, ITransientDependency { - public class OrderPlacedEventHandler : IDistributedEventHandler, ITransientDependency - { - private readonly IBasketRepository _basketRepository; + private readonly IBasketRepository _basketRepository; - public OrderPlacedEventHandler(IBasketRepository basketRepository) - { - _basketRepository = basketRepository; - } + public OrderPlacedEventHandler(IBasketRepository basketRepository) + { + _basketRepository = basketRepository; + } - [UnitOfWork] - public async Task HandleEventAsync(OrderPlacedEto eventData) - { - var basket = await _basketRepository.GetAsync(eventData.Buyer.BuyerId.GetValueOrDefault()); - basket.Clear(); - await _basketRepository.UpdateAsync(basket); - } + [UnitOfWork] + public async Task HandleEventAsync(OrderPlacedEto eventData) + { + var basket = await _basketRepository.GetAsync(eventData.Buyer.BuyerId.GetValueOrDefault()); + basket.Clear(); + await _basketRepository.UpdateAsync(basket); } } \ No newline at end of file From 69a60999aaa842894f8289afeb66a43d0c506f04 Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Tue, 6 Jun 2023 16:01:19 -0400 Subject: [PATCH 6/6] CmsKitService updated to use file-scoped namespaces --- .../EntityFrameworkCore/ICmskitServiceDbContext.cs | 9 ++++----- .../CmskitServiceDatabaseMigrationChecker.cs | 6 ++---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/services/cmskit/src/EShopOnAbp.CmskitService.EntityFrameworkCore/EntityFrameworkCore/ICmskitServiceDbContext.cs b/services/cmskit/src/EShopOnAbp.CmskitService.EntityFrameworkCore/EntityFrameworkCore/ICmskitServiceDbContext.cs index 0961ea61..747b7b2a 100644 --- a/services/cmskit/src/EShopOnAbp.CmskitService.EntityFrameworkCore/EntityFrameworkCore/ICmskitServiceDbContext.cs +++ b/services/cmskit/src/EShopOnAbp.CmskitService.EntityFrameworkCore/EntityFrameworkCore/ICmskitServiceDbContext.cs @@ -1,10 +1,9 @@ using Volo.Abp.Data; using Volo.Abp.EntityFrameworkCore; -namespace EShopOnAbp.CmskitService.EntityFrameworkCore +namespace EShopOnAbp.CmskitService.EntityFrameworkCore; + +[ConnectionStringName(CmskitServiceDbProperties.ConnectionStringName)] +public interface ICmskitServiceDbContext : IEfCoreDbContext { - [ConnectionStringName(CmskitServiceDbProperties.ConnectionStringName)] - public interface ICmskitServiceDbContext : IEfCoreDbContext - { - } } \ No newline at end of file diff --git a/services/cmskit/src/EShopOnAbp.CmskitService.HttpApi.Host/DbMigrations/CmskitServiceDatabaseMigrationChecker.cs b/services/cmskit/src/EShopOnAbp.CmskitService.HttpApi.Host/DbMigrations/CmskitServiceDatabaseMigrationChecker.cs index a121009b..e1d4aa5e 100644 --- a/services/cmskit/src/EShopOnAbp.CmskitService.HttpApi.Host/DbMigrations/CmskitServiceDatabaseMigrationChecker.cs +++ b/services/cmskit/src/EShopOnAbp.CmskitService.HttpApi.Host/DbMigrations/CmskitServiceDatabaseMigrationChecker.cs @@ -8,8 +8,7 @@ using Volo.Abp.Uow; namespace EShopOnAbp.CmskitService.DbMigrations; -public class CmskitServiceDatabaseMigrationChecker - : PendingEfCoreMigrationsChecker +public class CmskitServiceDatabaseMigrationChecker : PendingEfCoreMigrationsChecker { public CmskitServiceDatabaseMigrationChecker( IUnitOfWorkManager unitOfWorkManager, @@ -25,6 +24,5 @@ public class CmskitServiceDatabaseMigrationChecker abpDistributedLock, CmskitServiceDbProperties.ConnectionStringName) { - } -} +} \ No newline at end of file