CourseWork_Hotel/Hotel/HotelRestApi/Controllers/ReportController.cs

48 lines
1.4 KiB
C#

using HotelContracts.BindingModels;
using HotelContracts.BusinessLogicsContracts;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace HotelRestApi.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]
public class ReportController : Controller
{
private readonly ILogger _logger;
private readonly IReportOrganiserLogic _reportOrganiserLogic;
public ReportController(ILogger<ReportController> logger, IReportOrganiserLogic reportOrganiserLogic)
{
_logger = logger;
_reportOrganiserLogic = reportOrganiserLogic;
}
[HttpPost]
public void CreateReportToWordFile(ReportBindingModel model)
{
try
{
_reportOrganiserLogic.SaveMemberConferenceToWordFile(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания отчета");
throw;
}
}
[HttpPost]
public void CreateReportToExcelFile(ReportBindingModel model)
{
try
{
_reportOrganiserLogic.SaveMemberConferenceToExcelFile(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания отчета");
throw;
}
}
}
}