From d1bf5e20ab90b22d956fe9d1bfef2f620e0de806 Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Fri, 7 Jan 2022 14:41:26 +0300 Subject: [PATCH] conflict resolve --- .../Orders/OrderAppService.cs | 5 ++- .../Orders/IOrderRepository.cs | 2 +- .../Orders/EfCoreOrderRepository.cs | 13 ++++--- .../OrderClientProxy.Generated.cs | 8 ++++ .../ordering-generate-proxy.json | 37 +++++++++++++++++++ .../Orders/OrderRepository_Tests.cs | 37 ++++++++++++++++++- 6 files changed, 92 insertions(+), 10 deletions(-) diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Application/Orders/OrderAppService.cs b/services/ordering/src/EShopOnAbp.OrderingService.Application/Orders/OrderAppService.cs index 16ab85ba..69473e93 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.Application/Orders/OrderAppService.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.Application/Orders/OrderAppService.cs @@ -39,9 +39,10 @@ public class OrderAppService : ApplicationService, IOrderAppService return CreateOrderDtoMapping(orders); } - public Task GetByOrderNoAsync(int orderNo) + public async Task GetByOrderNoAsync(int orderNo) { - var order = await _orderRepository.get + var order = await _orderRepository.GetByOrderNoAsync(orderNo); + return CreateOrderDtoMapping(order); } public async Task CreateAsync(OrderCreateDto input) diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/IOrderRepository.cs b/services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/IOrderRepository.cs index 99db859f..a9494c97 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/IOrderRepository.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/IOrderRepository.cs @@ -15,7 +15,7 @@ public interface IOrderRepository : IRepository bool includeDetails = true, CancellationToken cancellationToken = default); - Task GetByOrderNoAsync(int orderNo, + Task GetByOrderNoAsync(int orderNo, bool includeDetails = true, CancellationToken cancellationToken = default); } \ 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 f8114346..2e45bb5a 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Orders/EfCoreOrderRepository.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Orders/EfCoreOrderRepository.cs @@ -35,12 +35,13 @@ public class EfCoreOrderRepository : EfCoreRepositoryq.Buyer.Id == userId) - .Where(spec.ToExpression()) - .OrderByDescending(o=>o.OrderDate) - .ToListAsync(GetCancellationToken(cancellationToken)); - + .IncludeDetails(includeDetails) + .Where(q => q.Buyer.Id == userId) + .Where(spec.ToExpression()) + .OrderByDescending(o => o.OrderDate) + .ToListAsync(GetCancellationToken(cancellationToken)); + } + public async Task GetByOrderNoAsync( int orderNo, bool includeDetails = true, diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/OrderClientProxy.Generated.cs b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/OrderClientProxy.Generated.cs index daa66900..34926156 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/OrderClientProxy.Generated.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/OrderClientProxy.Generated.cs @@ -32,6 +32,14 @@ namespace EShopOnAbp.OrderingService.Orders.ClientProxies }); } + public virtual async Task GetByOrderNoAsync(int orderNo) + { + return await RequestAsync(nameof(GetByOrderNoAsync), new ClientProxyRequestTypeValue + { + { typeof(int), orderNo } + }); + } + public virtual async Task CreateAsync(OrderCreateDto input) { return await RequestAsync(nameof(CreateAsync), new ClientProxyRequestTypeValue diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/ordering-generate-proxy.json b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/ordering-generate-proxy.json index 99f70346..ecfb20cf 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/ordering-generate-proxy.json +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/ordering-generate-proxy.json @@ -97,6 +97,43 @@ "allowAnonymous": null, "implementFrom": "EShopOnAbp.OrderingService.Orders.IOrderAppService" }, + "GetByOrderNoAsyncByOrderNo": { + "uniqueName": "GetByOrderNoAsyncByOrderNo", + "name": "GetByOrderNoAsync", + "httpMethod": "GET", + "url": "api/ordering/order/by-order-no", + "supportedVersions": [], + "parametersOnMethod": [ + { + "name": "orderNo", + "typeAsString": "System.Int32, System.Private.CoreLib", + "type": "System.Int32", + "typeSimple": "number", + "isOptional": false, + "defaultValue": null + } + ], + "parameters": [ + { + "nameOnMethod": "orderNo", + "name": "orderNo", + "jsonName": null, + "type": "System.Int32", + "typeSimple": "number", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "" + } + ], + "returnValue": { + "type": "EShopOnAbp.OrderingService.Orders.OrderDto", + "typeSimple": "EShopOnAbp.OrderingService.Orders.OrderDto" + }, + "allowAnonymous": null, + "implementFrom": "EShopOnAbp.OrderingService.Orders.IOrderAppService" + }, "CreateAsyncByInput": { "uniqueName": "CreateAsyncByInput", "name": "CreateAsync", diff --git a/services/ordering/test/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests/EntityFrameworkCore/Orders/OrderRepository_Tests.cs b/services/ordering/test/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests/EntityFrameworkCore/Orders/OrderRepository_Tests.cs index e16d6194..dd60c26f 100644 --- a/services/ordering/test/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests/EntityFrameworkCore/Orders/OrderRepository_Tests.cs +++ b/services/ordering/test/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests/EntityFrameworkCore/Orders/OrderRepository_Tests.cs @@ -1,4 +1,6 @@ -using System.Linq; +using System; +using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using EShopOnAbp.OrderingService.Orders; using EShopOnAbp.OrderingService.Orders.Specifications; @@ -14,9 +16,11 @@ public class OrderRepository_Tests : SampleRepository_Tests(); _dbContext = GetRequiredService(); _orderRepository = GetRequiredService(); _testData = GetRequiredService(); @@ -39,6 +43,37 @@ public class OrderRepository_Tests : SampleRepository_Tests(); + orderItems.Add((Guid.NewGuid(), "Test product", "Code:001", 15, 0, "", 1)); + var createdOrder = await _orderManager.CreateOrderAsync( + 1, + Guid.Parse("11CA0F6D-208E-441A-9F9B-3611C96E4383"), + "gterdem", + "gterdem@volosoft.com", + orderItems, + "Test Street", + "Test City", + "Test Country", + "Test zipCode"); + + createdOrder.ShouldNotBeNull(); + + // Get order + var order = await _orderRepository.GetByOrderNoAsync(createdOrder.OrderNo); + order.OrderNo.ShouldBe(createdOrder.OrderNo); + order.OrderItems.Count.ShouldBe(1); + order.OrderStatus.ShouldBe(OrderStatus.Placed); + order.PaymentStatus.ShouldBe("Waiting"); + } + [Fact] public async Task Should_Get_Users_Last_Year_Orders() {