using Microsoft.AspNetCore.Mvc; using RT.Application.Services; namespace RT.API.Controllers; [ApiController] [Route("api/[controller]")] public abstract class BaseController( IService service) : ControllerBase { [HttpGet] public async Task GetAll(CancellationToken ct) { var result = await service.GetAllAsync(ct); return Ok(result); } [HttpGet("{id:guid}")] public async Task GetById(Guid id, CancellationToken ct) { var result = await service.GetByIdAsync(id, ct); return result is null ? NotFound() : Ok(result); } [HttpPost] public async Task Create([FromBody] TCreate dto, CancellationToken ct) { var result = await service.CreateAsync(dto, ct); return Ok(result); } [HttpPut("{id:guid}")] public async Task 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 Delete(Guid id, CancellationToken ct) { await service.DeleteAsync(id, ct); return NoContent(); } }