67 lines
2.0 KiB
C#
67 lines
2.0 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using ServiceStationContracts.BindingModels;
|
|
using ServiceStationContracts.BusinessLogicsContracts;
|
|
|
|
namespace ServiceStationRestApi.Controllers
|
|
{
|
|
[Route("api/[controller]/[action]")]
|
|
[ApiController]
|
|
public class ReportController : Controller
|
|
{
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|