31 lines
1.2 KiB
C#
31 lines
1.2 KiB
C#
using FruitBank.Common.Dtos;
|
|
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 OrderItemDtoDbTable : MgDbTableBase<OrderItemDto>
|
|
{
|
|
public OrderItemDtoDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings, ILogger logger)
|
|
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger)
|
|
{
|
|
}
|
|
|
|
public IQueryable<OrderItemDto> GetAll(bool loadRelations)
|
|
{
|
|
return GetAll()
|
|
.LoadWith(oi => oi.OrderDto)
|
|
.LoadWith(oi => oi.OrderItemPallets)
|
|
.LoadWith(oi => oi.GenericAttributes)
|
|
.LoadWith(oi => oi.ProductDto).ThenLoad(prod => prod.GenericAttributes);
|
|
}
|
|
|
|
public Task<OrderItemDto> GetByIdAsync(int orderItemId) => GetAll(true).Where(x => x.Id == orderItemId).FirstOrDefaultAsync(null);
|
|
|
|
public IQueryable<OrderItemDto> GetAllByOrderId(int orderId)=> GetAll(true).Where(o => o.OrderId == orderId);
|
|
} |