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.
56 lines
2.1 KiB
C#
56 lines
2.1 KiB
C#
using Distribution.Models;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Distribution.Features.ChequeBook;
|
|
|
|
[ApiController]
|
|
[Route("api")]
|
|
public class ChequeBookController(ChequeBookService service) : ControllerBase
|
|
{
|
|
[HttpGet("cheque-books")]
|
|
public async Task<IActionResult> List(
|
|
[FromQuery] Guid? bankAccountId,
|
|
[FromQuery] int? branchId,
|
|
[FromQuery] ChequeBookStatus? status,
|
|
[FromQuery] int page = 1,
|
|
[FromQuery] int pageSize = 50)
|
|
=> Ok(await service.ListAsync(bankAccountId, branchId, status, page, pageSize));
|
|
|
|
[HttpGet("cheque-books/{chequeBookNo}")]
|
|
public async Task<IActionResult> Get(string chequeBookNo, [FromQuery] string? expand)
|
|
{
|
|
var expandPages = string.Equals(expand, "pages", StringComparison.OrdinalIgnoreCase);
|
|
var result = await service.GetAsync(chequeBookNo, expandPages);
|
|
return result is null ? NotFound() : Ok(result);
|
|
}
|
|
|
|
[HttpPost("cheque-books")]
|
|
public async Task<IActionResult> Create(CreateChequeBookRequest request, CancellationToken ct)
|
|
{
|
|
try { return Ok(await service.CreateAsync(request, ct)); }
|
|
catch (InvalidOperationException ex) { return BadRequest(new { error = ex.Message }); }
|
|
}
|
|
|
|
[HttpPut("cheque-pages/{chequeNo}/issue")]
|
|
public async Task<IActionResult> Issue(string chequeNo, IssueChequePageRequest request, CancellationToken ct)
|
|
{
|
|
try
|
|
{
|
|
var result = await service.IssueAsync(chequeNo, request, ct);
|
|
return result is null ? NotFound() : Ok(result);
|
|
}
|
|
catch (InvalidOperationException ex) { return BadRequest(new { error = ex.Message }); }
|
|
}
|
|
|
|
[HttpPut("cheque-pages/{chequeNo}/status")]
|
|
public async Task<IActionResult> UpdateStatus(string chequeNo, UpdateChequePageStatusRequest request, CancellationToken ct)
|
|
{
|
|
try
|
|
{
|
|
var result = await service.UpdatePageStatusAsync(chequeNo, request, ct);
|
|
return result is null ? NotFound() : Ok(result);
|
|
}
|
|
catch (InvalidOperationException ex) { return BadRequest(new { error = ex.Message }); }
|
|
}
|
|
}
|