2024-05-26 16:27:14 +04:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2024-05-27 21:44:16 +04:00
|
|
|
|
using ServiceStationContracts.BindingModels;
|
|
|
|
|
using ServiceStationContracts.BusinessLogicsContracts;
|
2024-05-26 16:27:14 +04:00
|
|
|
|
|
|
|
|
|
namespace ServiceStationRestApi.Controllers
|
|
|
|
|
{
|
|
|
|
|
[Route("api/[controller]/[action]")]
|
|
|
|
|
[ApiController]
|
|
|
|
|
public class ReportController : Controller
|
|
|
|
|
{
|
2024-05-27 21:44:16 +04:00
|
|
|
|
private readonly ILogger _logger;
|
|
|
|
|
private readonly IExecutorReportLogic _executorReportLogic;
|
|
|
|
|
|
|
|
|
|
public ReportController(ILogger<ReportController> logger, IExecutorReportLogic executorReportLogic)
|
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
_executorReportLogic = executorReportLogic;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateExecutorReportToWord(ReportExecutorBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_executorReportLogic.SaveWorkByCarsWordFile(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка создания отчета");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateExecutorReportToExcel(ReportExecutorBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_executorReportLogic.SaveWorkByCarsToExcelFile(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка создания отчета");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateExecutorReportToPdf(ReportExecutorBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_executorReportLogic.SaveTechWorkAndRepairsByCarsToPdfFile(new ReportExecutorBindingModel
|
|
|
|
|
{
|
|
|
|
|
FileName = model.FileName,
|
|
|
|
|
DateFrom = model.DateFrom,
|
|
|
|
|
DateTo = model.DateTo,
|
|
|
|
|
ExecutorId = model.ExecutorId,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка создания отчета");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-26 16:27:14 +04:00
|
|
|
|
}
|
|
|
|
|
}
|