From 1b0c774583f15b2db22c625b1a0f551c13576406 Mon Sep 17 00:00:00 2001 From: malik masis Date: Wed, 24 Aug 2022 16:10:39 +0300 Subject: [PATCH] Combined the actions --- .../Orders/IOrderRepository.cs | 12 ++----- .../Orders/EfCoreOrderRepository.cs | 31 ++----------------- 2 files changed, 4 insertions(+), 39 deletions(-) diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/IOrderRepository.cs b/services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/IOrderRepository.cs index 0e953790..97e3fd77 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/IOrderRepository.cs +++ b/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 bool includeDetails = true, CancellationToken cancellationToken = default); - Task> GetTopSelling( - ISpecification spec, - bool includeDetails = true, - CancellationToken cancellationToken = default); - - Task> GetPercentOfTotalPayment( - ISpecification spec, - CancellationToken cancellationToken = default); - - Task> GetCountOfTotalOrderStatus( + Task> GetDashboardAsync( ISpecification spec, bool includeDetails = true, CancellationToken cancellationToken = default); diff --git a/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Orders/EfCoreOrderRepository.cs b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Orders/EfCoreOrderRepository.cs index b717a372..f84e01d2 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Orders/EfCoreOrderRepository.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Orders/EfCoreOrderRepository.cs @@ -45,35 +45,8 @@ public class EfCoreOrderRepository : EfCoreRepository o.OrderDate) .ToListAsync(GetCancellationToken(cancellationToken)); } - - public async Task> GetTopSelling( - ISpecification 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> GetPercentOfTotalPayment( - ISpecification spec, - CancellationToken cancellationToken = default) - { - return await (await GetDbSetAsync()) - .Where(spec.ToExpression()) - .ToListAsync(GetCancellationToken(cancellationToken)); - } - - public async Task> GetCountOfTotalOrderStatus( + + public async Task> GetDashboardAsync( ISpecification spec, bool includeDetails = true, CancellationToken cancellationToken = default)