39 lines
1.4 KiB
C#
39 lines
1.4 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<OrderDto>
|
|
{
|
|
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()
|
|
.LoadWith(o => o.GenericAttributes)
|
|
.LoadWith(o => o.OrderItemDtos).ThenLoad(oi => oi.ProductDto)
|
|
.LoadWith(o => o.OrderItemDtos).ThenLoad(oi => oi.GenericAttributes)
|
|
.LoadWith(o => o.OrderItemDtos).ThenLoad(oi => oi.OrderItemPallets);
|
|
}
|
|
|
|
public Task<OrderDto> GetDtoByIdAsync(int orderId)
|
|
{
|
|
return GetAllDtos().Where(x => x.Id == orderId).FirstOrDefaultAsync(null);
|
|
}
|
|
|
|
public IQueryable<OrderDto> GetAllByStatusDto(OrderStatus orderStatus)
|
|
=> GetAllDtos().Where(o => o.OrderStatusId == (int)orderStatus);
|
|
}
|