Spaces:
Runtime error
Runtime error
Download src/SCM.Api/Controllers/ObrasController.cs from rafaeldavila/scm-api: direct link, hf CLI and curl.
- Browser
- Download file 3.19 kB
-
https://huggingface.co/spaces/rafaeldavila/scm-api/resolve/main/src/SCM.Api/Controllers/ObrasController.cs
- Command line
-
hf download hf://spaces/rafaeldavila/scm-api/src/SCM.Api/Controllers/ObrasController.cs
-
curl -L -o ObrasController.cs https://huggingface.co/spaces/rafaeldavila/scm-api/resolve/main/src/SCM.Api/Controllers/ObrasController.cs
3.19 kB
| using Asp.Versioning; | |
| using Microsoft.AspNetCore.Authorization; | |
| using Microsoft.AspNetCore.Mvc; | |
| using SCM.Application.Obras; | |
| using SCM.Application.Obras.Dtos; | |
| using SCM.Shared.Api; | |
| using SCM.Shared.Constants; | |
| namespace SCM.Api.Controllers; | |
| /// <summary>Cadastro-base de obras.</summary> | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| public sealed class ObrasController : ControllerBase | |
| { | |
| private readonly IObraService _service; | |
| public ObrasController(IObraService service) => _service = service; | |
| /// <summary>Lista todas as obras (ordenadas por código).</summary> | |
| [] | |
| [] | |
| public async Task<ActionResult<IReadOnlyList<ObraResponse>>> GetAll(CancellationToken ct = default) | |
| => Ok(await _service.GetAllAsync(ct)); | |
| /// <summary>Obtém uma obra pelo identificador.</summary> | |
| [] | |
| [] | |
| [] | |
| public async Task<ActionResult<ObraResponse>> GetById(Guid id, CancellationToken ct = default) | |
| => Ok(await _service.GetByIdAsync(id, ct)); | |
| /// <summary>Cria uma obra.</summary> | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| public async Task<ActionResult<ObraResponse>> Create( | |
| [] CreateObraRequest 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 uma obra.</summary> | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| public async Task<ActionResult<ObraResponse>> Update( | |
| Guid id, [FromBody] UpdateObraRequest request, CancellationToken ct = default) | |
| => Ok(await _service.UpdateAsync(id, request, ct)); | |
| /// <summary>Exclui uma obra (bloqueado se possuir registros vinculados).</summary> | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| public async Task<IActionResult> Delete(Guid id, CancellationToken ct = default) | |
| { | |
| await _service.DeleteAsync(id, ct); | |
| return NoContent(); | |
| } | |
| } | |