Browse Source

Combined the actions

pull/125/head
malik masis 4 years ago
parent
commit
1b0c774583
  1. 12
      services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/IOrderRepository.cs
  2. 31
      services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Orders/EfCoreOrderRepository.cs

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

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
@ -20,16 +21,7 @@ public interface IOrderRepository : IRepository<Order, Guid>
bool includeDetails = true,
CancellationToken cancellationToken = default);
Task<List<OrderItem>> GetTopSelling(
ISpecification<Order> spec,
bool includeDetails = true,
CancellationToken cancellationToken = default);
Task<List<Order>> GetPercentOfTotalPayment(
ISpecification<Order> spec,
CancellationToken cancellationToken = default);
Task<List<Order>> GetCountOfTotalOrderStatus(
Task<List<Order>> GetDashboardAsync(
ISpecification<Order> spec,
bool includeDetails = true,
CancellationToken cancellationToken = default);

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

@ -45,35 +45,8 @@ public class EfCoreOrderRepository : EfCoreRepository<OrderingServiceDbContext,
.OrderByDescending(o => o.OrderDate)
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<List<OrderItem>> GetTopSelling(
ISpecification<Order> spec,
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
return (await (await GetDbSetAsync())
.IncludeDetails(includeDetails)
.Where(spec.ToExpression())
.SelectMany(oi => oi.OrderItems)
.GroupBy(p => p.ProductCode)
.OrderByDescending(o => o.Sum(p => p.Units))
.Select(o => o.ToList())
.ToListAsync())
.SelectMany(t => t)
.Take(OrderConstants.Top10)
.ToList();
}
public async Task<List<Order>> GetPercentOfTotalPayment(
ISpecification<Order> spec,
CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
.Where(spec.ToExpression())
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<List<Order>> GetCountOfTotalOrderStatus(
public async Task<List<Order>> GetDashboardAsync(
ISpecification<Order> spec,
bool includeDetails = true,
CancellationToken cancellationToken = default)

Loading…
Cancel
Save