using FruitBank.Common.Entities; using LinqToDB; using Mango.Nop.Core.Repositories; using Nop.Core.Caching; using Nop.Core.Configuration; using Nop.Core.Events; using Nop.Data; using Nop.Services.Logging; namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer; public class ShippingDocumentDbTable : MgDbTableBase { public ShippingDocumentDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings, ILogger logger) : base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger) { } public override IOrderedQueryable GetAll() => base.GetAll().OrderBy(sd => sd.ShippingDate); public IQueryable GetAll(bool loadRelations) { return loadRelations ? GetAll() .LoadWith(sd => sd.Shipping) .LoadWith(sd => sd.ShippingItems).ThenLoad(si => si.Pallet) .LoadWith(sd => sd.ShippingItems).ThenLoad(si => si.Product) .LoadWith(sd => sd.ShippingItems).ThenLoad(si => si.ShippingItemPallets) .LoadWith(sd => sd.ShippingDocumentToFiles).ThenLoad(sdtof => sdtof.ShippingDocumentFile) .LoadWith(sd => sd.Partner) : GetAll(); } public IQueryable GetAllNotMeasured(bool loadRelations) => GetAll(loadRelations).Where(sd => !sd.IsAllMeasured); public Task GetByIdAsync(int id, bool loadRelations) => GetAll(loadRelations).FirstOrDefaultAsync(sd => sd.Id == id); }