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 { public OrderDtoDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings, ILogger logger) : base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger) { } public IQueryable 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 GetDtoByIdAsync(int orderId) { return GetAllDtos().Where(x => x.Id == orderId).FirstOrDefaultAsync(null); } public IQueryable GetAllByStatusDto(OrderStatus orderStatus) => GetAllDtos().Where(o => o.OrderStatusId == (int)orderStatus); }