97 lines
2.7 KiB
C#
97 lines
2.7 KiB
C#
using BankYouBankruptBusinessLogic.BusinessLogics;
|
||
using BankYouBankruptContracts.BindingModels;
|
||
using BankYouBankruptContracts.BusinessLogicsContracts;
|
||
using BankYouBankruptContracts.SearchModels;
|
||
using BankYouBankruptContracts.ViewModels;
|
||
using BankYouBankruptRestApi.Controllers;
|
||
using DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing;
|
||
using Microsoft.AspNetCore.Mvc;
|
||
using Org.BouncyCastle.Utilities;
|
||
using System.Net;
|
||
|
||
namespace BankYouBankruptRestAPI.Controllers
|
||
{
|
||
//указание у контроллера, что Route будет строиться не только по наванию контроллера, но и по названию метода (так как у нас два Post-метода)
|
||
[Route("api/[controller]/[action]")]
|
||
[ApiController]
|
||
public class ReportController : Controller
|
||
{
|
||
private readonly ILogger _logger;
|
||
|
||
//private readonly IReportCashierLogic _reportCashierLogic;
|
||
|
||
private readonly IReportClientLogic _reportClientLogic;
|
||
|
||
private readonly IReportCashierLogic _reportCashierLogic;
|
||
|
||
private readonly IReportLoad _reportLoad;
|
||
|
||
public ReportController(ILogger<ReportController> logger, IReportClientLogic reportClientLogic, IReportCashierLogic reportCashierLogic, IReportLoad reportLoad)
|
||
{
|
||
_logger = logger;
|
||
_reportClientLogic = reportClientLogic;
|
||
_reportCashierLogic = reportCashierLogic;
|
||
_reportLoad = reportLoad;
|
||
}
|
||
|
||
//метод генерации отчёта за период по картам клиента
|
||
[HttpPost]
|
||
public void CreateClientReport(ReportSupportBindingModel model)
|
||
{
|
||
try
|
||
{
|
||
_reportClientLogic.SaveClientReportToPdfFile(new ReportBindingModel
|
||
{
|
||
FileName = "Отчёт_по_картам.pdf",
|
||
DateFrom = model.DateFrom,
|
||
DateTo = model.DateTo
|
||
});
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
_logger.LogError(ex, "Ошибка входа в систему");
|
||
throw;
|
||
}
|
||
}
|
||
|
||
//метод генерации отчёта по всем счетм клиентов
|
||
[HttpPost]
|
||
public void CreateCashierReport(ReportSupportBindingModel model)
|
||
{
|
||
try
|
||
{
|
||
_reportCashierLogic.SaveAccountsToPdfFile(new ReportBindingModel
|
||
{
|
||
FileName = "Отчёт_по_счетам.pdf",
|
||
ClientId = model.ClientId,
|
||
DateFrom = model.DateFrom,
|
||
DateTo = model.DateTo
|
||
});
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
_logger.LogError(ex, "Ошибка входа в систему");
|
||
throw;
|
||
}
|
||
}
|
||
|
||
[HttpGet]
|
||
public PdfLoadViewModel LoadReport(bool whoRequested)
|
||
{
|
||
try
|
||
{
|
||
PdfLoadViewModel model = new PdfLoadViewModel();
|
||
|
||
model.bytes = _reportLoad.LoadFile(whoRequested);
|
||
|
||
return model;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
_logger.LogError(ex, "Ошибка входа в систему");
|
||
throw;
|
||
}
|
||
}
|
||
}
|
||
}
|