CourseWork_CompShop/ComputerShopProvider/ComputerShopRestApi/Controllers/ReportController.cs

64 lines
1.8 KiB
C#
Raw Normal View History

2023-05-18 22:18:40 +04:00
using ComputerShopContracts.BindingModels;
using ComputerShopContracts.SearchModels;
using ComputerShopContracts.ViewModels;
using ComputerShopBusinessLogic.BusinessLogics;
using Microsoft.AspNetCore.Mvc;
using ComputerShopContracts.BusinessLogicContracts;
[Route("api/[controller]/[action]")]
[ApiController]
public class ReportController : Controller
{
private readonly ILogger _logger;
private readonly IReportLogic _reportLogic;
public ReportController(ILogger<ReportController> logger, IReportLogic reportLogic)
{
_logger = logger;
_reportLogic = reportLogic;
}
[HttpPost]
public void CreateDocReport(ReportBindingModel model)
{
try
{
_reportLogic.SaveReceivingComponentsToWordFile(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания отчета");
throw;
}
}
[HttpPost]
public void CreateXmlReport(ReportBindingModel model)
{
try
{
_reportLogic.SaveReceivingComponentsToXmlFile(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания отчета");
throw;
}
}
2023-05-24 21:14:10 +04:00
[HttpPost]
public void CreatePdfReport(ReportBindingModel model)
{
try
{
_reportLogic.SavePurchaseSuppliesToPdfFile(new ReportBindingModel
{
DateFrom = model.DateFrom,
DateTo = model.DateTo,
FileName = "F:\\ReportsCourseWork\\pdffile.pdf",
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания отчета");
throw;
}
}
2023-05-18 22:18:40 +04:00
}