35 lines
1.2 KiB
C#
35 lines
1.2 KiB
C#
using FruitBank.Common.Dtos;
|
|
using FruitBank.Common.Entities;
|
|
using LinqToDB;
|
|
using Mango.Nop.Core.Repositories;
|
|
using Nop.Core.Caching;
|
|
using Nop.Core.Configuration;
|
|
using Nop.Core.Domain.Orders;
|
|
using Nop.Core.Events;
|
|
using Nop.Data;
|
|
using Nop.Services.Logging;
|
|
|
|
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
|
|
|
|
|
public class OrderDtoDbTable : MgDbTableBase<Order>
|
|
{
|
|
public OrderDtoDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings, ILogger logger)
|
|
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger)
|
|
{
|
|
}
|
|
|
|
public IQueryable<OrderDto> GetAllDtos()
|
|
{
|
|
return GetAll().Select(o => new OrderDto(o));
|
|
}
|
|
|
|
public Task<OrderDto> GetDtoByIdAsync(int orderId)
|
|
{
|
|
return GetAll().Where(x => x.Id == orderId).Select(o => new OrderDto(o)).FirstOrDefaultAsync(null);
|
|
}
|
|
|
|
public IQueryable<OrderDto> GetAllByStatusDto(OrderStatus orderStatus)
|
|
=> GetAll().Where(o => o.OrderStatusId == (int)orderStatus).Select(o => new OrderDto(o));
|
|
}
|