37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
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 ShippingDbTable : MgDbTableBase<Shipping>
|
|
{
|
|
public ShippingDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings, ILogger logger)
|
|
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger)
|
|
{
|
|
}
|
|
|
|
public override IOrderedQueryable<Shipping> GetAll()
|
|
=> base.GetAll().OrderBy(s => s.ShippingDate);
|
|
|
|
public IQueryable<Shipping> GetAll(bool loadRelations)
|
|
{
|
|
return loadRelations
|
|
? GetAll()
|
|
.LoadWith(sd => sd.ShippingDocuments).ThenLoad(si => si.ShippingItems)
|
|
.LoadWith(sd => sd.ShippingDocuments).ThenLoad(p => p.Partner)
|
|
: GetAll();
|
|
}
|
|
|
|
public IQueryable<Shipping> GetNotMeasured(bool loadRelations)
|
|
=> GetAll(loadRelations).Where(s => !s.IsAllMeasured);
|
|
|
|
|
|
public Task<Shipping> GetByIdAsync(int id, bool loadRelations)
|
|
=> GetAll(loadRelations).FirstOrDefaultAsync(s => s.Id == id);
|
|
} |