using FruitBank.Common.Entities; using FruitBank.Common.Enums; using LinqToDB; using Mango.Nop.Data.Repositories; using Nop.Core.Caching; using Nop.Core.Configuration; using Nop.Core.Events; using Nop.Data; using Mango.Nop.Core.Loggers; namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer; public class OrderDraftDbTable : MgDbTableBase { public OrderDraftDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings) : base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings) { } public IQueryable GetAll(bool loadRelations) { return loadRelations ? GetAll().LoadWith(d => d.Items) : GetAll(); } public Task GetByIdAsync(int id, bool loadRelations) => GetAll(loadRelations).FirstOrDefaultAsync(d => d.Id == id); public IQueryable GetPending() => GetAll().Where(d => d.Status == OrderDraftStatus.Pending); public IQueryable GetExpiredCandidates() => GetAll().Where(d => d.Status == OrderDraftStatus.Pending && d.CreatedOnUtc <= DateTime.UtcNow.AddDays(-14)); }