Browse Source

conflict resolve

pull/56/head
Galip Tolga Erdem 4 years ago
parent
commit
d1bf5e20ab
  1. 5
      services/ordering/src/EShopOnAbp.OrderingService.Application/Orders/OrderAppService.cs
  2. 2
      services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/IOrderRepository.cs
  3. 13
      services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Orders/EfCoreOrderRepository.cs
  4. 8
      services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/OrderClientProxy.Generated.cs
  5. 37
      services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/ordering-generate-proxy.json
  6. 37
      services/ordering/test/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests/EntityFrameworkCore/Orders/OrderRepository_Tests.cs

5
services/ordering/src/EShopOnAbp.OrderingService.Application/Orders/OrderAppService.cs

@ -39,9 +39,10 @@ public class OrderAppService : ApplicationService, IOrderAppService
return CreateOrderDtoMapping(orders);
}
public Task<OrderDto> GetByOrderNoAsync(int orderNo)
public async Task<OrderDto> GetByOrderNoAsync(int orderNo)
{
var order = await _orderRepository.get
var order = await _orderRepository.GetByOrderNoAsync(orderNo);
return CreateOrderDtoMapping(order);
}
public async Task<OrderDto> CreateAsync(OrderCreateDto input)

2
services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/IOrderRepository.cs

@ -15,7 +15,7 @@ public interface IOrderRepository : IRepository<Order, Guid>
bool includeDetails = true,
CancellationToken cancellationToken = default);
Task<Order> GetByOrderNoAsync(int orderNo,
Task<Order> GetByOrderNoAsync(int orderNo,
bool includeDetails = true,
CancellationToken cancellationToken = default);
}

13
services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Orders/EfCoreOrderRepository.cs

@ -35,12 +35,13 @@ public class EfCoreOrderRepository : EfCoreRepository<OrderingServiceDbContext,
CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
.IncludeDetails(includeDetails)
.Where(q=>q.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<Order> GetByOrderNoAsync(
int orderNo,
bool includeDetails = true,

8
services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/OrderClientProxy.Generated.cs

@ -32,6 +32,14 @@ namespace EShopOnAbp.OrderingService.Orders.ClientProxies
});
}
public virtual async Task<OrderDto> GetByOrderNoAsync(int orderNo)
{
return await RequestAsync<OrderDto>(nameof(GetByOrderNoAsync), new ClientProxyRequestTypeValue
{
{ typeof(int), orderNo }
});
}
public virtual async Task<OrderDto> CreateAsync(OrderCreateDto input)
{
return await RequestAsync<OrderDto>(nameof(CreateAsync), new ClientProxyRequestTypeValue

37
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",

37
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<OrderingServiceEntit
private readonly TestData _testData;
private readonly IOrderRepository _orderRepository;
private readonly IOrderingServiceDbContext _dbContext;
private readonly OrderManager _orderManager;
public OrderRepository_Tests()
{
_orderManager = GetRequiredService<OrderManager>();
_dbContext = GetRequiredService<IOrderingServiceDbContext>();
_orderRepository = GetRequiredService<IOrderRepository>();
_testData = GetRequiredService<TestData>();
@ -39,6 +43,37 @@ public class OrderRepository_Tests : SampleRepository_Tests<OrderingServiceEntit
var firstOrder = orders.First();
firstOrder.OrderItems.Count.ShouldBe(5);
}
[Fact]
public async Task Should_Get_Order_By_OrderNo()
{
// Create new order
var orderItems =
new List<(Guid productId, string productName, string productCode, decimal unitPrice, decimal discount,
string pictureUrl, int
units)>();
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()
{

Loading…
Cancel
Save