This commit is contained in:
Adam 2025-10-13 18:06:38 +02:00
commit 7f53fccc4f
5 changed files with 26 additions and 27 deletions

View File

@ -38,12 +38,10 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
} }
#region CustomOrderSignalREndpoint #region CustomOrderSignalREndpoint
public Task<List<OrderDto>> GetAllOrderDtos() [NonAction] public Task<List<OrderDto>> GetAllOrderDtos() => _customOrderSignalREndpoint.GetAllOrderDtos();
=> _customOrderSignalREndpoint.GetAllOrderDtos(); [NonAction]public Task<OrderDto> GetOrderDtoById(int orderId) => _customOrderSignalREndpoint.GetOrderDtoById(orderId);
public Task<OrderDto> GetOrderDtoById(int orderId) [NonAction]public Task<List<OrderDto>> GetPendingOrderDtos() => _customOrderSignalREndpoint.GetPendingOrderDtos();
=> _customOrderSignalREndpoint.GetOrderDtoById(orderId); [NonAction] public Task<List<OrderDto>> GetAllByIds(int[] orderIds) => _customOrderSignalREndpoint.GetAllByIds(orderIds);
public Task<List<OrderDto>> GetPendingOrderDtos()
=> _customOrderSignalREndpoint.GetPendingOrderDtos();
#endregion CustomOrderSignalREndpoint #endregion CustomOrderSignalREndpoint
[CheckPermission(StandardPermission.Orders.ORDERS_VIEW)] [CheckPermission(StandardPermission.Orders.ORDERS_VIEW)]
@ -87,16 +85,6 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
return orderListModel; return orderListModel;
} }
public async Task<OrderListModelExtended> GetPendingOrderListModel()
{
var orderSearchModel = new OrderSearchModel
{
OrderStatusIds = new List<int> { (int)OrderStatus.Pending }
};
return await GetOrderListModelByFilter(orderSearchModel);
}
public virtual IActionResult Test() public virtual IActionResult Test()
{ {
// Your custom logic here // Your custom logic here

View File

@ -12,18 +12,24 @@ public class CustomOrderSignalREndpoint(FruitBankDbContext ctx) : ICustomOrderSi
[SignalR(SignalRTags.GetAllOrderDtos)] [SignalR(SignalRTags.GetAllOrderDtos)]
public async Task<List<OrderDto>> GetAllOrderDtos() public async Task<List<OrderDto>> GetAllOrderDtos()
{ {
return await ctx.OrderDtos.GetAllDtos().ToListAsync(); return await ctx.OrderDtos.GetAll(true).ToListAsync();
} }
[SignalR(SignalRTags.GetOrderDtoById)] [SignalR(SignalRTags.GetOrderDtoById)]
public async Task<OrderDto> GetOrderDtoById(int orderId) public async Task<OrderDto> GetOrderDtoById(int orderId)
{ {
return await ctx.OrderDtos.GetDtoByIdAsync(orderId); return await ctx.OrderDtos.GetByIdAsync(orderId);
} }
[SignalR(SignalRTags.GetPendingOrderDtos)] [SignalR(SignalRTags.GetPendingOrderDtos)]
public async Task<List<OrderDto>> GetPendingOrderDtos() public async Task<List<OrderDto>> GetPendingOrderDtos()
{ {
return await ctx.OrderDtos.GetAllByStatusDto(OrderStatus.Pending).ToListAsync(); return await ctx.OrderDtos.GetAllByOrderStatus(OrderStatus.Pending).ToListAsync();
}
[SignalR(SignalRTags.GetAllByIdList)]
public async Task<List<OrderDto>> GetAllByIds(int[] orderIds)
{
return await ctx.OrderDtos.GetAllByIds(orderIds).ToListAsync();
} }
} }

View File

@ -275,7 +275,7 @@ public class FruitBankDbContext : MgDbContextBase,
foreach (var shippingItemPallet in shippingItem.ShippingItemPallets!.Where(x => x.IsMeasured && x.IsValidMeasuringValues(shippingItem.IsMeasurable))) foreach (var shippingItemPallet in shippingItem.ShippingItemPallets!.Where(x => x.IsMeasured && x.IsValidMeasuringValues(shippingItem.IsMeasurable)))
{ {
shippingItem.MeasuredQuantity += shippingItemPallet.Quantity; shippingItem.MeasuredQuantity += shippingItemPallet.TrayQuantity;
if (!shippingItem.IsMeasurable) continue; if (!shippingItem.IsMeasurable) continue;
shippingItem.MeasuredNetWeight += shippingItemPallet.NetWeight; shippingItem.MeasuredNetWeight += shippingItemPallet.NetWeight;

View File

@ -19,20 +19,25 @@ public class OrderDtoDbTable : MgDbTableBase<OrderDto>
{ {
} }
public IQueryable<OrderDto> GetAllDtos() public IQueryable<OrderDto> GetAll(bool loadRelations)
{ {
return GetAll() return GetAll()
.LoadWith(o => o.GenericAttributes) .LoadWith(o => o.GenericAttributes)
.LoadWith(o => o.OrderItemDtos).ThenLoad(oi => oi.ProductDto) .LoadWith(o => o.OrderItemDtos).ThenLoad(oi => oi.ProductDto).ThenLoad(prod=>prod.GenericAttributes)
.LoadWith(o => o.OrderItemDtos).ThenLoad(oi => oi.GenericAttributes) .LoadWith(o => o.OrderItemDtos).ThenLoad(oi => oi.GenericAttributes)
.LoadWith(o => o.OrderItemDtos).ThenLoad(oi => oi.OrderItemPallets); .LoadWith(o => o.OrderItemDtos).ThenLoad(oi => oi.OrderItemPallets);
} }
public Task<OrderDto> GetDtoByIdAsync(int orderId) public Task<OrderDto> GetByIdAsync(int orderId)
{ {
return GetAllDtos().Where(x => x.Id == orderId).FirstOrDefaultAsync(null); return GetAll(true).Where(x => x.Id == orderId).FirstOrDefaultAsync(null);
} }
public IQueryable<OrderDto> GetAllByStatusDto(OrderStatus orderStatus) public IQueryable<OrderDto> GetAllByOrderStatus(OrderStatus orderStatus)
=> GetAllDtos().Where(o => o.OrderStatusId == (int)orderStatus); => GetAll(true).Where(o => o.OrderStatusId == (int)orderStatus);
public IQueryable<OrderDto> GetAllByIds(IEnumerable<int> orderIds)
{
return GetAll(true).Where(o => orderIds.Contains(o.Id));
}
} }

View File

@ -32,7 +32,7 @@ public class OrderItemPalletDbTable : MeasuringItemPalletBaseDbTable<OrderItemPa
public IQueryable<OrderItemPallet> GetAll(bool loadRelations) public IQueryable<OrderItemPallet> GetAll(bool loadRelations)
{ {
return loadRelations return loadRelations
? GetAll().LoadWith(oip => oip.OrderItem) ? GetAll().LoadWith(oip => oip.OrderItemDto).ThenLoad(oi => oi.ProductDto)
: GetAll(); : GetAll();
} }