Spaces:
Runtime error
Runtime error
Download src/SCM.Api/Controllers/ContratosController.cs from rafaeldavila/scm-api: direct link, hf CLI and curl.
- Browser
- Download file 4.58 kB
-
https://huggingface.co/spaces/rafaeldavila/scm-api/resolve/main/src/SCM.Api/Controllers/ContratosController.cs
- Command line
-
hf download hf://spaces/rafaeldavila/scm-api/src/SCM.Api/Controllers/ContratosController.cs
-
curl -L -o ContratosController.cs https://huggingface.co/spaces/rafaeldavila/scm-api/resolve/main/src/SCM.Api/Controllers/ContratosController.cs
4.58 kB
| using Asp.Versioning; | |
| using Microsoft.AspNetCore.Authorization; | |
| using Microsoft.AspNetCore.Mvc; | |
| using SCM.Application.Contratos; | |
| using SCM.Application.Contratos.Dtos; | |
| using SCM.Shared.Api; | |
| using SCM.Shared.Constants; | |
| namespace SCM.Api.Controllers; | |
| /// <summary>Cadastro de contratos (por obra).</summary> | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| public sealed class ContratosController : ControllerBase | |
| { | |
| private readonly IContratoService _service; | |
| public ContratosController(IContratoService service) => _service = service; | |
| /// <summary>Lista os contratos de uma obra (ordenados por código).</summary> | |
| [] | |
| [] | |
| public async Task<ActionResult<IReadOnlyList<ContratoResponse>>> GetByObra( | |
| [] Guid obraId, CancellationToken ct = default) | |
| => Ok(await _service.GetByObraAsync(obraId, ct)); | |
| /// <summary>Obtém um contrato pelo identificador.</summary> | |
| [] | |
| [] | |
| [] | |
| public async Task<ActionResult<ContratoResponse>> GetById(Guid id, CancellationToken ct = default) | |
| => Ok(await _service.GetByIdAsync(id, ct)); | |
| /// <summary>Cria um contrato.</summary> | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| public async Task<ActionResult<ContratoResponse>> Create( | |
| [] CreateContratoRequest request, CancellationToken ct = default) | |
| { | |
| var created = await _service.CreateAsync(request, ct); | |
| return CreatedAtAction(nameof(GetById), new { id = created.Id, version = "1.0" }, created); | |
| } | |
| /// <summary>Altera um contrato (a obra é imutável).</summary> | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| public async Task<ActionResult<ContratoResponse>> Update( | |
| Guid id, [FromBody] UpdateContratoRequest request, CancellationToken ct = default) | |
| => Ok(await _service.UpdateAsync(id, request, ct)); | |
| /// <summary>Calcula a semana do contrato (1-based, ancorada na segunda-feira) em que a data cai.</summary> | |
| [] | |
| [] | |
| [] | |
| [] | |
| public async Task<ActionResult<SemanaContratoResponse>> ObterSemanaPorData( | |
| Guid id, [FromQuery] DateOnly data, CancellationToken ct = default) | |
| => Ok(await _service.ObterSemanaPorDataAsync(id, data, ct)); | |
| /// <summary>Retorna o intervalo (segunda a domingo) da semana informada (1-based).</summary> | |
| [] | |
| [] | |
| [] | |
| [] | |
| public async Task<ActionResult<SemanaContratoResponse>> ObterSemanaPorNumero( | |
| Guid id, int semana, CancellationToken ct = default) | |
| => Ok(await _service.ObterSemanaPorNumeroAsync(id, semana, ct)); | |
| /// <summary>Exclui um contrato (bloqueado se possuir critérios vinculados).</summary> | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| public async Task<IActionResult> Delete(Guid id, CancellationToken ct = default) | |
| { | |
| await _service.DeleteAsync(id, ct); | |
| return NoContent(); | |
| } | |
| } | |