* Further improvements to generate PackList
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user