CourseWork_CompShop/ComputerShopProvider/ComputerShopRestApi/Controllers/ReportController.cs

46 lines
1.2 KiB
C#

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;
}
}
}