49 lines
2.1 KiB
C#
49 lines
2.1 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using SytelineSaAppEfDataModel.Dtos;
|
|
using SytelineSaAppEfDataModel.Services;
|
|
|
|
namespace FaKrosnoApi.Controllers
|
|
{
|
|
[ApiController]
|
|
[Route("api/[controller]")]
|
|
public class CustomerOrdersController(ICustomerOrderService service) : Controller
|
|
{
|
|
[HttpGet]
|
|
public async Task<ActionResult<IEnumerable<CustomerOrderDto>>> GetAll()
|
|
{
|
|
IEnumerable<CustomerOrderDto?> customerOrders = await service.GetAll();
|
|
return Ok(customerOrders);
|
|
}
|
|
|
|
[HttpGet("by-order-number")]
|
|
public async Task<ActionResult<CustomerOrderDto?>> GetByCustomerOrderNumber([FromQuery] Guid customerOrderNumber)
|
|
{
|
|
CustomerOrderDto? customerOrder = await service.GetByOrderNumber(customerOrderNumber);
|
|
return customerOrder != null ? Ok(customerOrder) : NotFound();
|
|
}
|
|
|
|
[HttpGet("by-co-number")]
|
|
public async Task<ActionResult<CustomerOrderDto?>> GetByCoNumber([FromQuery] string customerOrderNumber)
|
|
{
|
|
CustomerOrderDto? customerOrder = await service.GetByCoNumber(customerOrderNumber);
|
|
return customerOrder != null ? Ok(customerOrder) : NotFound();
|
|
}
|
|
|
|
[HttpGet("items-by-co-number")]
|
|
public async Task<ActionResult<CustomerOrderDto?>> GetItemsByCoNumber([FromQuery] string customerOrderNumber)
|
|
{
|
|
var customerOrderLineItems = await service.GetItemsByCoNumber(customerOrderNumber);
|
|
return customerOrderLineItems != null ? Ok(customerOrderLineItems) : NotFound();
|
|
}
|
|
|
|
[HttpGet("by-customer-and-po")]
|
|
public async Task<ActionResult<CustomerOrderDto?>> GetByCustomerAndPo([FromQuery] string customerNumber, [FromQuery] int customerSequence, [FromQuery] string poNumber)
|
|
{
|
|
CustomerOrderDto? customerOrder =
|
|
await service.GetByCustomerAndPo(customerNumber, customerSequence, poNumber);
|
|
return customerOrder != null ? Ok(customerOrder) : NotFound();
|
|
}
|
|
}
|
|
}
|