mirror of
https://gitlab.com/Hukuta47/cartrix.git
synced 2026-12-05 12:30:55 +00:00
Добавил маршрут ListCausesForReplace
This commit is contained in:
1 parent
0106a85570
commit
76c1e89f31
3 files changed
+15
-4
No files matched your search
@@ -1,9 +1,11 @@
|
||||
using iText.IO.Source;
|
||||
using CartriX.Api.Entities;
|
||||
using iText.IO.Source;
|
||||
|
||||
namespace CartriX.Api.Controllers.Report
|
||||
{
|
||||
public interface IReportService
|
||||
{
|
||||
public Task<byte[]?> GenerateFileRequestToReplaceCartridge(int RequestId);
|
||||
public Task<List<CauseFoReplace>> GetCausesToReplaceAsync();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using CartriX.Shared.Models.Report;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace CartriX.Api.Controllers.Report
|
||||
{
|
||||
@@ -14,10 +15,16 @@ namespace CartriX.Api.Controllers.Report
|
||||
[Produces("application/pdf")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<IActionResult> DownloadPdfFileRequest([FromQuery] int RequestId)
|
||||
public async Task<ActionResult> DownloadPdfFileRequest([FromQuery] int RequestId)
|
||||
{
|
||||
byte[]? pdfBytes = await _reportService.GenerateFileRequestToReplaceCartridge(RequestId);
|
||||
return (pdfBytes is not null) ? File(pdfBytes, "application/pdf", $"Заявка на обслуживание техники №{RequestId}.pdf") : StatusCode(StatusCodes.Status404NotFound);
|
||||
}
|
||||
/// <summary>
|
||||
/// Получить список причин замены
|
||||
/// </summary>
|
||||
[HttpGet(nameof(ListCausesForReplace))]
|
||||
[ProducesResponseType(typeof(List<CauseForReplaceItem>),StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult> ListCausesForReplace() => Ok((await _reportService.GetCausesToReplaceAsync()).Select(c => c.ToItem()));
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using CartriX.Api.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace CartriX.Api.Controllers.Report
|
||||
{
|
||||
@@ -11,5 +12,6 @@ namespace CartriX.Api.Controllers.Report
|
||||
var Request = await _context.RequestsToReplaceCartridge.Include(r => r.Cause).FirstOrDefaultAsync(r => r.Id == RequestId);
|
||||
return (Request is not null) ? Shared.Classes.RequestReplaceFileGenerator.Generate(Request.ToData()) : null;
|
||||
}
|
||||
public async Task<List<CauseFoReplace>> GetCausesToReplaceAsync() => await _context.CausesFoReplace.ToListAsync();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user