Spaces:
Runtime error
Runtime error
Download src/SCM.Api/Controllers/FuncionariosController.cs from rafaeldavila/scm-api: direct link, hf CLI and curl.
- Browser
- Download file 3.31 kB
-
https://huggingface.co/spaces/rafaeldavila/scm-api/resolve/main/src/SCM.Api/Controllers/FuncionariosController.cs
- Command line
-
hf download hf://spaces/rafaeldavila/scm-api/src/SCM.Api/Controllers/FuncionariosController.cs
-
curl -L -o FuncionariosController.cs https://huggingface.co/spaces/rafaeldavila/scm-api/resolve/main/src/SCM.Api/Controllers/FuncionariosController.cs
3.31 kB
| using Asp.Versioning; | |
| using Microsoft.AspNetCore.Authorization; | |
| using Microsoft.AspNetCore.Mvc; | |
| using SCM.Application.Planejamento; | |
| using SCM.Application.Planejamento.Dtos; | |
| using SCM.Shared.Api; | |
| using SCM.Shared.Constants; | |
| namespace SCM.Api.Controllers; | |
| /// <summary>Módulo MPL — funcionários (pessoal de obra).</summary> | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| public sealed class FuncionariosController : ControllerBase | |
| { | |
| private readonly IFuncionarioService _service; | |
| public FuncionariosController(IFuncionarioService service) => _service = service; | |
| /// <summary>Lista todos os funcionários (ordenados por nome).</summary> | |
| [] | |
| [] | |
| public async Task<ActionResult<IReadOnlyList<FuncionarioResponse>>> GetAll(CancellationToken ct = default) | |
| => Ok(await _service.GetAllAsync(ct)); | |
| /// <summary>Obtém um funcionário pelo identificador.</summary> | |
| [] | |
| [] | |
| [] | |
| public async Task<ActionResult<FuncionarioResponse>> GetById(Guid id, CancellationToken ct = default) | |
| => Ok(await _service.GetByIdAsync(id, ct)); | |
| /// <summary>Cria um funcionário.</summary> | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| public async Task<ActionResult<FuncionarioResponse>> Create( | |
| [] CreateFuncionarioRequest 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 funcionário (matrícula é imutável).</summary> | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| public async Task<ActionResult<FuncionarioResponse>> Update( | |
| Guid id, [FromBody] UpdateFuncionarioRequest request, CancellationToken ct = default) | |
| => Ok(await _service.UpdateAsync(id, request, ct)); | |
| /// <summary>Exclui um funcionário (bloqueado se estiver alocado em equipe).</summary> | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| public async Task<IActionResult> Delete(Guid id, CancellationToken ct = default) | |
| { | |
| await _service.DeleteAsync(id, ct); | |
| return NoContent(); | |
| } | |
| } | |