Spaces:
Runtime error
Runtime error
Download src/SCM.Api/Controllers/RelatoriosPdfController.cs from rafaeldavila/scm-api: direct link, hf CLI and curl.
- Browser
- Download file 2.75 kB
-
https://huggingface.co/spaces/rafaeldavila/scm-api/resolve/main/src/SCM.Api/Controllers/RelatoriosPdfController.cs
- Command line
-
hf download hf://spaces/rafaeldavila/scm-api/src/SCM.Api/Controllers/RelatoriosPdfController.cs
-
curl -L -o RelatoriosPdfController.cs https://huggingface.co/spaces/rafaeldavila/scm-api/resolve/main/src/SCM.Api/Controllers/RelatoriosPdfController.cs
2.75 kB
| using Asp.Versioning; | |
| using Microsoft.AspNetCore.Authorization; | |
| using Microsoft.AspNetCore.Mvc; | |
| using SCM.Application.Controle; | |
| using SCM.Application.Medicao; | |
| using SCM.Application.Qualidade; | |
| using SCM.Application.Relatorios; | |
| using SCM.Shared.Api; | |
| namespace SCM.Api.Controllers; | |
| /// <summary>Geração de PDFs dos relatórios (faturamento, acompanhamento, relatório técnico).</summary> | |
| [] | |
| [] | |
| [] | |
| [] | |
| public sealed class RelatoriosPdfController : ControllerBase | |
| { | |
| private readonly IPdfReportService _pdf; | |
| public RelatoriosPdfController(IPdfReportService pdf) => _pdf = pdf; | |
| /// <summary>PDF do faturamento por EAP do contrato.</summary> | |
| [] | |
| [] | |
| [] | |
| public async Task<IActionResult> FaturamentoPdf( | |
| Guid contratoId, [FromServices] IFaturamentoService faturamento, CancellationToken ct = default) | |
| { | |
| var dados = await faturamento.GetFaturamentoAsync(contratoId, ct); | |
| var bytes = _pdf.Faturamento(dados); | |
| return File(bytes, "application/pdf", $"faturamento-{contratoId}.pdf"); | |
| } | |
| /// <summary>PDF do resumo de acompanhamento da obra na data.</summary> | |
| [] | |
| [] | |
| [] | |
| public async Task<IActionResult> AcompanhamentoPdf( | |
| Guid obraId, [FromQuery] DateOnly data, | |
| [FromServices] IAcompanhamentoService acompanhamento, CancellationToken ct = default) | |
| { | |
| var foto = await acompanhamento.GetFotoAsync(obraId, data, ct); | |
| var historico = await acompanhamento.GetHistoricoAsync(obraId, ct); | |
| var bytes = _pdf.Acompanhamento(foto, historico); | |
| return File(bytes, "application/pdf", $"acompanhamento-{obraId}.pdf"); | |
| } | |
| /// <summary>PDF de um relatório técnico.</summary> | |
| [] | |
| [] | |
| [] | |
| public async Task<IActionResult> RelatorioTecnicoPdf( | |
| Guid id, [FromServices] IRelatorioTecnicoService relatorios, CancellationToken ct = default) | |
| { | |
| // GetByProducao/GetByObra retornam listas; aqui buscamos o RT específico pela obra dele. | |
| var rt = await relatorios.GetByIdAsync(id, ct); | |
| var bytes = _pdf.RelatorioTecnico(rt); | |
| return File(bytes, "application/pdf", $"relatorio-tecnico-{rt.Numero}.pdf"); | |
| } | |
| } | |