using FruitBank.Common.Dtos; using FruitBank.Common.Entities; 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 Nop.Services.Logging; namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer; public class OrderDtoDbTable : MgDbTableBase { public OrderDtoDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings, ILogger logger) : base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger) { } public IQueryable GetAllDtos() { return GetAll().Select(o => new OrderDto(o)); } public Task GetDtoByIdAsync(int orderId) { return GetAll().Where(x => x.Id == orderId).Select(o => new OrderDto(o)).FirstOrDefaultAsync(null); } public IQueryable GetAllByStatusDto(OrderStatus orderStatus) => GetAll().Where(o => o.OrderStatusId == (int)orderStatus).Select(o => new OrderDto(o)); }