87c807c16c
- Implemented ChequeBooksPage for viewing and filtering cheque books. - Added NewReceivedChequePage for recording received cheques. - Created ReceivedChequesPage for listing and managing received cheques. - Introduced API endpoints for bank accounts, cheque books, and received cheques. - Defined types for payments including bank accounts, cheque books, and received cheques.
67 lines
2.4 KiB
C#
67 lines
2.4 KiB
C#
using Distribution.Models;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Distribution.Features.BankAccount;
|
|
|
|
[ApiController]
|
|
[Route("api")]
|
|
public class BankAccountController(BankAccountService service) : ControllerBase
|
|
{
|
|
[HttpGet("bank-accounts")]
|
|
public async Task<IActionResult> List([FromQuery] BankAccountType? accountType)
|
|
{
|
|
var result = await service.ListAsync(accountType);
|
|
return Ok(result);
|
|
}
|
|
|
|
[HttpPost("bank-accounts")]
|
|
public async Task<IActionResult> CreateBank(CreateBankAccountRequest request, CancellationToken ct)
|
|
{
|
|
try { return Ok(await service.CreateBankAsync(request, ct)); }
|
|
catch (InvalidOperationException ex) { return BadRequest(new { error = ex.Message }); }
|
|
}
|
|
|
|
[HttpPost("cash-accounts")]
|
|
public async Task<IActionResult> CreateCash(CreateCashAccountRequest request, CancellationToken ct)
|
|
{
|
|
try { return Ok(await service.CreateCashAsync(request, ct)); }
|
|
catch (InvalidOperationException ex) { return BadRequest(new { error = ex.Message }); }
|
|
}
|
|
|
|
[HttpPut("cash-accounts/{id:guid}")]
|
|
public async Task<IActionResult> UpdateCash(Guid id, UpdateCashAccountRequest request, CancellationToken ct)
|
|
{
|
|
try
|
|
{
|
|
var result = await service.UpdateCashAsync(id, request, ct);
|
|
return result is null ? NotFound() : Ok(result);
|
|
}
|
|
catch (InvalidOperationException ex) { return BadRequest(new { error = ex.Message }); }
|
|
}
|
|
|
|
[HttpPatch("cash-accounts/{id:guid}/status")]
|
|
public async Task<IActionResult> SetCashStatus(Guid id, SetCashAccountStatusRequest request, CancellationToken ct)
|
|
{
|
|
try
|
|
{
|
|
var result = await service.SetCashStatusAsync(id, request, ct);
|
|
return result is null ? NotFound() : Ok(result);
|
|
}
|
|
catch (InvalidOperationException ex) { return BadRequest(new { error = ex.Message }); }
|
|
}
|
|
|
|
[HttpDelete("cash-accounts/{id:guid}")]
|
|
public async Task<IActionResult> DeleteCash(Guid id, CancellationToken ct)
|
|
{
|
|
try
|
|
{
|
|
var ok = await service.DeleteCashAsync(id, ct);
|
|
return ok ? NoContent() : NotFound();
|
|
}
|
|
catch (InvalidOperationException ex) { return BadRequest(new { error = ex.Message }); }
|
|
}
|
|
|
|
[HttpGet("cash-account-types")]
|
|
public async Task<IActionResult> ListCashAccountTypes() => Ok(await service.ListCashAccountTypesAsync());
|
|
}
|