5cb32bee95
This reverts commit 9adfff48a7.
27 lines
841 B
C#
27 lines
841 B
C#
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Distribution.Features.Payment;
|
|
|
|
[ApiController]
|
|
[Route("api/invoices/{invoiceId:guid}/payments")]
|
|
public class PaymentController(PaymentService service) : ControllerBase
|
|
{
|
|
[HttpGet]
|
|
public async Task<IActionResult> GetByInvoice(Guid invoiceId)
|
|
{
|
|
var result = await service.GetByInvoiceIdAsync(invoiceId);
|
|
return result is null ? NotFound() : Ok(result);
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<IActionResult> Create(Guid invoiceId, CreatePaymentRequest request, CancellationToken ct)
|
|
{
|
|
try
|
|
{
|
|
var result = await service.CreateAsync(invoiceId, request, ct);
|
|
return result is null ? NotFound() : Ok(result);
|
|
}
|
|
catch (InvalidOperationException ex) { return BadRequest(new { error = ex.Message }); }
|
|
}
|
|
}
|