Initial Commit

This commit is contained in:
Emmanuel Rojas committed 2026-09-04 12:26:23 -05:00
commit bd7e505432
22 files changed
+871

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
using Microsoft.AspNetCore.Mvc;
using RT.Application.Services;
namespace RT.API.Controllers;
[ApiController]
[Route("api/[controller]")]
public abstract class BaseController<TCreate, TUpdate, TResponse>(
IService<TCreate, TUpdate, TResponse> service) : ControllerBase
{
[HttpGet]
public async Task<IActionResult> GetAll(CancellationToken ct)
{
var result = await service.GetAllAsync(ct);
return Ok(result);
}
[HttpGet("{id:guid}")]
public async Task<IActionResult> GetById(Guid id, CancellationToken ct)
{
var result = await service.GetByIdAsync(id, ct);
return result is null ? NotFound() : Ok(result);
}
[HttpPost]
public async Task<IActionResult> Create([FromBody] TCreate dto, CancellationToken ct)
{
var result = await service.CreateAsync(dto, ct);
return Ok(result);
}
[HttpPut("{id:guid}")]
public async Task<IActionResult> Update(Guid id, [FromBody] TUpdate dto, CancellationToken ct)
{
var result = await service.UpdateAsync(id, dto, ct);
return Ok(result);
}
[HttpDelete("{id:guid}")]
public async Task<IActionResult> Delete(Guid id, CancellationToken ct)
{
await service.DeleteAsync(id, ct);
return NoContent();
}
}