* Further improvements to generate PackList

This commit is contained in:
2025-05-17 18:36:11 +02:00
parent bc28c5d63d
commit 6ab3960e50
20 changed files with 671 additions and 191 deletions

View File

@@ -1,9 +1,4 @@
using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using SytelineSaAppEfDataModel.Dtos;
@@ -22,7 +17,7 @@ namespace SytelineSaAppEfDataModel.Services
.Where(x => x.RowPointer == orderNumber)
.Select(x => mapper.Map<CustomerOrderDto>(x)).FirstOrDefaultAsync();
if (customerOrder == null) return null;
customerOrder.CustomerOrderLines = await context.CustomerOrderLines
.Where(x => x.CoNum == customerOrder.CoNum)
.Select(x => mapper.Map<CustomerOrderLineDto>(x)).ToListAsync();
@@ -33,14 +28,50 @@ namespace SytelineSaAppEfDataModel.Services
.Where(x => x.CoNum == customerOrder.CoNum && x.CoLine == customerOrderLine.CoLine)
.Select(x => mapper.Map<CustomerOrderLineItemDto>(x)).ToListAsync();
}
IList<EdiCustomerOrderTranslateDto> ediCustomerOrderTranslates = await context.EdiCustomerOrderTranslates
.Where(x => x.CoCoNum == customerOrder.CoNum)
.Select(x => mapper.Map<EdiCustomerOrderTranslateDto>(x)).ToListAsync();
customerOrder.EdiCustomerOrderTranslates = ediCustomerOrderTranslates;
return customerOrder;
}
public async Task<CustomerOrderDto?> GetByCoNumber(string orderNumber)
{
CustomerOrderDto? customerOrder = await context.CustomerOrders
.Where(x => x.CoNum == orderNumber)
.Select(x => mapper.Map<CustomerOrderDto>(x)).FirstOrDefaultAsync();
if (customerOrder == null) return null;
customerOrder.CustomerOrderLines = await context.CustomerOrderLines
.Where(x => x.CoNum == customerOrder.CoNum)
.Select(x => mapper.Map<CustomerOrderLineDto>(x)).ToListAsync();
foreach (CustomerOrderLineDto customerOrderLine in customerOrder.CustomerOrderLines)
{
customerOrderLine.CustomerOrderLineItems = await context.CustomerOrderLineItems
.Where(x => x.CoNum == customerOrder.CoNum && x.CoLine == customerOrderLine.CoLine)
.Select(x => mapper.Map<CustomerOrderLineItemDto>(x)).ToListAsync();
}
IList<EdiCustomerOrderTranslateDto> ediCustomerOrderTranslates = await context.EdiCustomerOrderTranslates
.Where(x => x.CoCoNum == customerOrder.CoNum)
.Select(x => mapper.Map<EdiCustomerOrderTranslateDto>(x)).ToListAsync();
customerOrder.EdiCustomerOrderTranslates = ediCustomerOrderTranslates;
return customerOrder;
}
public async Task<IEnumerable<CustomerOrderLineItemDto>?> GetItemsByCoNumber(string customerOrderNumber)
{
List<CustomerOrderLineItemDto> customerOrderLineItems = await context.CustomerOrderLineItems
.Where(x => x.CoNum == customerOrderNumber)
.Select(x => mapper.Map<CustomerOrderLineItemDto>(x)).ToListAsync();
return customerOrderLineItems;
}
}
}
}