32 lines
1.3 KiB
C#
32 lines
1.3 KiB
C#
using FruitBank.Common.Dtos;
|
|
using LinqToDB;
|
|
using Mango.Nop.Core.Repositories;
|
|
using Nop.Core.Caching;
|
|
using Nop.Core.Configuration;
|
|
using Nop.Core.Domain.Orders;
|
|
using Nop.Core.Events;
|
|
using Nop.Data;
|
|
using Mango.Nop.Core.Loggers;
|
|
|
|
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
|
|
|
public class OrderItemDtoDbTable : MgDtoDbTableBase<OrderItemDto, OrderItem>
|
|
{
|
|
public OrderItemDtoDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings)
|
|
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings)
|
|
{
|
|
}
|
|
|
|
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, bool loadRelations) => GetAll(loadRelations).Where(x => x.Id == orderItemId).FirstOrDefaultAsync(null);
|
|
|
|
public IQueryable<OrderItemDto> GetAllByOrderId(int orderId, bool loadRelations = true)=> GetAll(loadRelations).Where(o => o.OrderId == orderId);
|
|
} |