Spaces:
Runtime error
Runtime error
Download src/SCM.Api/Controllers/RirsController.cs from rafaeldavila/scm-api: direct link, hf CLI and curl.
- Browser
- Download file 4.76 kB
-
https://huggingface.co/spaces/rafaeldavila/scm-api/resolve/main/src/SCM.Api/Controllers/RirsController.cs
- Command line
-
hf download hf://spaces/rafaeldavila/scm-api/src/SCM.Api/Controllers/RirsController.cs
-
curl -L -o RirsController.cs https://huggingface.co/spaces/rafaeldavila/scm-api/resolve/main/src/SCM.Api/Controllers/RirsController.cs
4.76 kB
| using Asp.Versioning; | |
| using Microsoft.AspNetCore.Authorization; | |
| using Microsoft.AspNetCore.Mvc; | |
| using SCM.Application.Materiais; | |
| using SCM.Application.Materiais.Dtos; | |
| using SCM.Shared.Api; | |
| using SCM.Shared.Constants; | |
| namespace SCM.Api.Controllers; | |
| /// <summary>RIRs — Relatórios de Inspeção de Recebimento (MSP).</summary> | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| public sealed class RirsController : ControllerBase | |
| { | |
| private readonly IRirService _service; | |
| public RirsController(IRirService service) => _service = service; | |
| /// <summary>Lista os RIRs (opcionalmente por agrupador), com seus itens.</summary> | |
| [] | |
| [] | |
| public async Task<ActionResult<IReadOnlyList<RirResponse>>> GetAll( | |
| [] Guid? agrupadorId = null, CancellationToken ct = default) | |
| => Ok(await _service.GetAllAsync(agrupadorId, ct)); | |
| /// <summary>Obtém um RIR pelo identificador.</summary> | |
| [] | |
| [] | |
| [] | |
| public async Task<ActionResult<RirResponse>> GetById(Guid id, CancellationToken ct = default) | |
| => Ok(await _service.GetByIdAsync(id, ct)); | |
| /// <summary>Cria um RIR agrupando DOs do mesmo agrupador (número gerado; nasce Pendente).</summary> | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| public async Task<ActionResult<RirResponse>> Create( | |
| [] CreateRirRequest request, CancellationToken ct = default) | |
| { | |
| var created = await _service.CreateAsync(request, ct); | |
| return CreatedAtAction(nameof(GetById), new { id = created.Id, version = "1.0" }, created); | |
| } | |
| /// <summary>Substitui os itens do RIR (o agrupador é imutável; data de criação é reescrita).</summary> | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| public async Task<ActionResult<RirResponse>> Update( | |
| Guid id, [FromBody] UpdateRirRequest request, CancellationToken ct = default) | |
| => Ok(await _service.UpdateAsync(id, request, ct)); | |
| /// <summary>Inspeciona o RIR (todos os itens, um único fiscal); o status é derivado dos laudos.</summary> | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| public async Task<ActionResult<RirResponse>> Inspecionar( | |
| Guid id, [FromBody] InspecionarRirRequest request, CancellationToken ct = default) | |
| => Ok(await _service.InspecionarAsync(id, request, ct)); | |
| /// <summary>Estorna as inspeções do RIR (volta ao estado Pendente).</summary> | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| public async Task<ActionResult<RirResponse>> Estornar(Guid id, CancellationToken ct = default) | |
| => Ok(await _service.EstornarAsync(id, ct)); | |
| /// <summary>Exclui um RIR e seus itens (bloqueado se houver item inspecionado).</summary> | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| public async Task<IActionResult> Delete(Guid id, CancellationToken ct = default) | |
| { | |
| await _service.DeleteAsync(id, ct); | |
| return NoContent(); | |
| } | |
| } | |