c775146b64
Implementation A partner, not just software HexDive Technologies' local team handles setup, data migration, training and ongoing support — in Sinhala, Tamil and English. [confirm] 1 Discovery Map your network, products and processes. 2 Configuration Set up depots, pricing, schemes, routes and users. 3 Migration & training Move your data and train every team. 4 Go-live & support Dedicated account manager and local support desk.
38 lines
1.3 KiB
C#
38 lines
1.3 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Distribution.Features.ExpenseVendor;
|
|
|
|
[ApiController]
|
|
[Route("api/expense-vendors")]
|
|
public class ExpenseVendorController(ExpenseVendorService service) : ControllerBase
|
|
{
|
|
[HttpGet]
|
|
[Authorize("expense.view")]
|
|
public async Task<IActionResult> List(
|
|
[FromQuery] string? search,
|
|
[FromQuery] int page = 1,
|
|
[FromQuery] int pageSize = 50) =>
|
|
Ok(await service.ListAsync(search, page, pageSize));
|
|
|
|
[HttpPost]
|
|
[Authorize("expense.manage_categories")]
|
|
public async Task<IActionResult> Create(CreateExpenseVendorRequest request, CancellationToken ct)
|
|
{
|
|
try { return Ok(await service.CreateAsync(request, ct)); }
|
|
catch (InvalidOperationException ex) { return BadRequest(new { error = ex.Message }); }
|
|
}
|
|
|
|
[HttpPut("{id:guid}")]
|
|
[Authorize("expense.manage_categories")]
|
|
public async Task<IActionResult> Update(Guid id, UpdateExpenseVendorRequest request, CancellationToken ct)
|
|
{
|
|
try
|
|
{
|
|
var result = await service.UpdateAsync(id, request, ct);
|
|
return result is null ? NotFound() : Ok(result);
|
|
}
|
|
catch (InvalidOperationException ex) { return BadRequest(new { error = ex.Message }); }
|
|
}
|
|
}
|