using FruitBank.Common.Dtos; using FruitBank.Common.Entities; using LinqToDB; using Mango.Nop.Core.Entities; using Mango.Nop.Core.Loggers; using Mango.Nop.Data.Repositories; using Nop.Core.Caching; using Nop.Core.Configuration; using Nop.Core.Domain.Catalog; using Nop.Core.Events; using Nop.Data; using System.Linq.Expressions; namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer; public class StockQuantityHistoryDtoDbTable : MgDtoDbTableBase { public StockQuantityHistoryDtoDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings) : base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings) { } public override IQueryable GetAll() => base.GetAll().LoadWith(sqh => sqh.StockQuantityHistoryExt); public IQueryable GetAll(bool loadProductRelation) { return loadProductRelation ? GetAll().LoadWith(sqh => sqh.ProductDto).ThenLoad(p => p.GenericAttributes) : GetAll(); } public Task GetByIdAsync(int id, bool loadProductRelation) => GetAll(loadProductRelation).FirstOrDefaultAsync(p => p.Id == id); public IQueryable GetByProductIdAsync(int productId, bool loadProductRelation) => GetAll(loadProductRelation).Where(p => p.ProductId == productId); }