* Extended CustomerOrdersController and CustomerOrderService

This commit is contained in:
2025-12-23 12:00:28 +01:00
parent c4b1561cbc
commit e9a3e91082
3 changed files with 15 additions and 0 deletions

View File

@@ -56,6 +56,13 @@ namespace FaKrosnoApi.Controllers
return customerOrder != null ? Ok(customerOrder) : NotFound();
}
[HttpGet("by-po")]
public async Task<ActionResult<CustomerOrderDto?>> GetByPo([FromQuery] string poNumber)
{
CustomerOrderDto? customerOrder = await service.GetByPo(poNumber);
return customerOrder != null ? Ok(customerOrder) : NotFound();
}
[HttpGet("list-by-customer-and-po")]
public async Task<ActionResult<IList<CustomerOrderDto?>>> GetListByCustomerAndPo(
[FromQuery] string customerNumber, [FromQuery] int customerSequence, [FromQuery] string poNumber)

View File

@@ -73,6 +73,13 @@ namespace SytelineSaAppEfDataModel.Services
.Select(x => mapper.Map<CustomerOrderDto>(x)).FirstOrDefaultAsync();
}
public async Task<CustomerOrderDto?> GetByPo(string poNumber)
{
return await context.CustomerOrders.Where(x => x.CustPo == poNumber && x.Stat == "O")
.OrderByDescending(x => x.CreateDate).Select(x => mapper.Map<CustomerOrderDto>(x))
.FirstOrDefaultAsync();
}
public async Task<IList<CustomerOrderDto>> GetListByCustomerAndPo(string customerNumber, int customerSequence,
string poNumber)
{

View File

@@ -17,6 +17,7 @@ namespace SytelineSaAppEfDataModel.Services
Task<IList<CustomerOrderDto>> GetListByCustomerAndPo(string customerNumber, int customerSequence,
string poNumber);
Task<CustomerOrderDto?> GetByPo(string poNumber);
Task<List<CustomerOrderDto>> GetListByCustomer(string customerNumber, int customerSequence);
Task<IEnumerable<CustomerOrderLineDto>?> GetLinesByCoNumber(string customerOrderNumber);
Task<IEnumerable<CustomerOrderLineItemDto>?> GetItemsByCoNumber(string customerOrderNumber);