diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportCashierLogic.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportCashierLogic.cs index ce029ea..373ad7a 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportCashierLogic.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportCashierLogic.cs @@ -25,12 +25,12 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics private readonly AbstractSaveToWordCashier _saveToWord; - private readonly AbstractSaveToPdfCashier _saveToPdf; + private readonly AbstractSaveToPdfClient _saveToPdf; //инициализируем поля класса через контейнер public ReportCashierLogic(IMoneyTransferStorage moneyTransferStorage, ICashWithdrawalStorage cashWithdrawalStorage, IAccountStorage accountStorage, AbstractSaveToExcelCashier saveToExcel, AbstractSaveToWordCashier saveToWord, - AbstractSaveToPdfCashier saveToPdf) + AbstractSaveToPdfClient saveToPdf) { _moneyTransferStorage = moneyTransferStorage; _cashWithdrawalStorage = cashWithdrawalStorage; @@ -41,25 +41,30 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics _saveToPdf = saveToPdf; } + //формирование списка переводов между счетами за период public List? GetMoneyTransfers(ReportBindingModel model) { return _moneyTransferStorage.GetFilteredList(new MoneyTransferSearchModel { DateFrom = model.DateFrom, DateTo = model.DateTo}) .Select(x => new ReportCashierViewModel { + OperationId = x.Id, DateComplite = x.DateOperation, - AccountPayeeId = x.AccountPayeeId, - AccountSenderId = x.AccountSenderId, + AccountPayeeNumber = x.AccountPayeeNumber, + AccountSenderNumber = x.AccountSenderNumber, SumOperation = x.Sum }) .ToList(); } + //формирование списка выдаци наличных со счёта за период public List? GetCashWithrawals(ReportBindingModel model) { return _cashWithdrawalStorage.GetFilteredList(new CashWithdrawalSearchModel { DateFrom = model.DateFrom, DateTo = model.DateTo }) .Select(x => new ReportCashierViewModel { - AccountPayeeId = x.Id, + OperationId = x.Id, + DebitingId = x.DebitingId, + AccountPayeeNumber = x.AccountNumber, DateComplite = x.DateOperation, SumOperation = x.Sum }) @@ -81,7 +86,16 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics //Сохранение заказов в файл-Pdf public void SaveAccountsToPdfFile(ReportBindingModel model) { - throw new NotImplementedException(); + _saveToPdf.CreateDoc(new PdfInfo + { + ForClient = false, + FileName = model.FileName, + Title = "Отчёт по операциям начислений и переводов между счетами", + DateFrom = model.DateFrom!.Value, + DateTo = model.DateTo!.Value, + ReportMoneyTransfer = GetMoneyTransfers(model), + ReportCashWithdrawal = GetCashWithrawals(model) + }); } } } diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToPdfCashier.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToPdfCashier.cs index 8cfd443..564617e 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToPdfCashier.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToPdfCashier.cs @@ -17,38 +17,65 @@ namespace BankYouBankruptBusinessLogic.OfficePackage CreateParagraph(new PdfParagraph { - Text = info.Title, - Style = "NormalTitle", + Text = info.Title + $"\nот {DateTime.Now.ToShortDateString()}", + Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); CreateParagraph(new PdfParagraph { - Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", + Text = $"Расчётный период: с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); - CreateTable(new List { "2cm", "3cm", "6cm", "3cm", "3cm" }); + //параграф с отчётом по выдаче наличных с карт + CreateParagraph(new PdfParagraph { Text = "Отчёт по выдаче наличных с карт", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); + + CreateTable(new List { "3cm", "3cm", "5cm", "5cm" }); CreateRow(new PdfRowParameters { - Texts = new List { "Номер", "Дата заказа", "Изделие", "Статус заказа", "Сумма" }, + Texts = new List { "Номер операции", "Номер счёта получателя", "Сумма операции", "Дата операции" }, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); - foreach (var report in info.Accounts) + foreach (var report in info.ReportCashWithdrawal) { CreateRow(new PdfRowParameters { - Texts = new List { report.AccountSenderId.ToString(), report.AccountPayeeId.ToString(), report.DateComplite.ToShortDateString(), report.SumOperation.ToString() }, + Texts = new List { report.OperationId.ToString(), report.AccountPayeeNumber.ToString(), report.SumOperation.ToString(), report.DateComplite.ToShortDateString(), }, Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Left }); } - //CreateParagraph(new PdfParagraph { Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Right }); + CreateParagraph(new PdfParagraph { Text = $"Итоговая сумма снятий за период: {info.ReportCashWithdrawal.Sum(x => x.SumOperation)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Right }); + + //параграф с отчётом по переводу денег со счёта на счёт + CreateParagraph(new PdfParagraph { Text = "Отчёт по денежным переводам между счетами", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); + + CreateTable(new List { "3cm", "3cm", "3cm", "5cm", "5cm" }); + + CreateRow(new PdfRowParameters + { + Texts = new List { "Номер операции", "Номер счёта отправителя", "Номер счёта получателя", "Сумма операции", "Дата операции" }, + Style = "NormalTitle", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + + foreach (var report in info.ReportMoneyTransfer) + { + CreateRow(new PdfRowParameters + { + Texts = new List { report.OperationId.ToString(), report.AccountSenderNumber, report.AccountPayeeNumber, report.SumOperation.ToString(), report.DateComplite.ToShortDateString(), }, + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Left + }); + } + + CreateParagraph(new PdfParagraph { Text = $"Итоговая сумма переводов за период: {info.ReportMoneyTransfer.Sum(x => x.SumOperation)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Right }); SavePdf(info); } diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToPdfClient.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToPdfClient.cs index 433c6cc..21589b3 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToPdfClient.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToPdfClient.cs @@ -13,27 +13,41 @@ namespace BankYouBankruptBusinessLogic.OfficePackage //публичный метод создания документа. Описание методов ниже public void CreateDoc(PdfInfo info) { - CreatePdf(info); + if(info.ForClient) + { + CreateDocClient(info); + } + else + { + CreateDocCashier(info); + } + } - CreateParagraph(new PdfParagraph - { - Text = info.Title + $"\nот { DateTime.Now.ToShortDateString() }", + #region Отчёт для клиента + + public void CreateDocClient(PdfInfo info) + { + CreatePdf(info); + + CreateParagraph(new PdfParagraph + { + Text = info.Title + $"\nот {DateTime.Now.ToShortDateString()}", Style = "NormalTitle", - ParagraphAlignment = PdfParagraphAlignmentType.Center - }); + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); - CreateParagraph(new PdfParagraph - { - Text = $"Расчётный период: с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", - Style = "Normal", - ParagraphAlignment = PdfParagraphAlignmentType.Center - }); + CreateParagraph(new PdfParagraph + { + Text = $"Расчётный период: с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); //параграф с отчётом на пополнения CreateParagraph(new PdfParagraph { Text = "Отчёт по пополнениям", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); - CreateTable(new List { "3cm", "3cm", "5cm", "5cm"}); + CreateTable(new List { "3cm", "3cm", "5cm", "5cm" }); CreateRow(new PdfRowParameters { @@ -83,8 +97,84 @@ namespace BankYouBankruptBusinessLogic.OfficePackage SavePdf(info); } - /// Создание pdf-файла - protected abstract void CreatePdf(PdfInfo info); + #endregion + + #region Отчёт для кассира + + //создание отчёта для кассира + public void CreateDocCashier(PdfInfo info) + { + CreatePdf(info); + + CreateParagraph(new PdfParagraph + { + Text = info.Title + $"\nот {DateTime.Now.ToShortDateString()}", + Style = "NormalTitle", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + + CreateParagraph(new PdfParagraph + { + Text = $"Расчётный период: с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + + //параграф с отчётом по выдаче наличных с карт + CreateParagraph(new PdfParagraph { Text = "Отчёт по выдаче наличных с карт", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); + + CreateTable(new List { "3.5cm", "3.5cm", "5cm", "5cm" }); + + CreateRow(new PdfRowParameters + { + Texts = new List { "Номер операции", "Номер счёта получателя", "Сумма операции", "Дата операции" }, + Style = "NormalTitle", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + + foreach (var report in info.ReportCashWithdrawal) + { + CreateRow(new PdfRowParameters + { + Texts = new List { report.OperationId.ToString(), report.AccountPayeeNumber, report.SumOperation.ToString(), report.DateComplite.ToShortDateString(), }, + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Left + }); + } + + CreateParagraph(new PdfParagraph { Text = $"Итоговая сумма снятий за период: {info.ReportCashWithdrawal.Sum(x => x.SumOperation)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Right }); + + //параграф с отчётом по переводу денег со счёта на счёт + CreateParagraph(new PdfParagraph { Text = "Отчёт по денежным переводам между счетами", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); + + CreateTable(new List { "3cm", "3cm", "3cm", "4cm", "4cm" }); + + CreateRow(new PdfRowParameters + { + Texts = new List { "Номер операции", "Номер счёта отправителя", "Номер счёта получателя", "Сумма операции", "Дата операции" }, + Style = "NormalTitle", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + + foreach (var report in info.ReportMoneyTransfer) + { + CreateRow(new PdfRowParameters + { + Texts = new List { report.OperationId.ToString(), report.AccountSenderNumber, report.AccountPayeeNumber, report.SumOperation.ToString(), report.DateComplite.ToShortDateString(), }, + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Left + }); + } + + CreateParagraph(new PdfParagraph { Text = $"Итоговая сумма переводов за период: {info.ReportMoneyTransfer.Sum(x => x.SumOperation)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Right }); + + SavePdf(info); + } + + #endregion + + /// Создание pdf-файла + protected abstract void CreatePdf(PdfInfo info); /// Создание параграфа с текстом protected abstract void CreateParagraph(PdfParagraph paragraph); diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs index 7cf9432..38fb1cc 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs @@ -18,13 +18,19 @@ namespace BankYouBankruptBusinessLogic.OfficePackage.HelperModels public DateTime DateTo { get; set; } + //по умолчанию отчёт делается для клиента + public bool ForClient { get; set; } = true; + //перечень заказов за указанный период для вывода/сохранения public List ReportCrediting { get; set; } = new(); //перечень заказов за указанный период для вывода/сохранения public List ReportDebiting { get; set; } = new(); - //перечень счетов для отчёта кассира - public List Accounts { get; set; } = new(); - } + //перечень переводов со счёта на счёт + public List ReportMoneyTransfer { get; set; } = new(); + + //перечень зачислений денежных средств на карту (т. е. на её счёт) + public List ReportCashWithdrawal { get; set; } = new(); + } } diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/Implements/SaveToExcelCashier.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/Implements/SaveToExcelCashier.cs new file mode 100644 index 0000000..d7f0c1f --- /dev/null +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/Implements/SaveToExcelCashier.cs @@ -0,0 +1,32 @@ +using BankYouBankruptBusinessLogic.OfficePackage.HelperModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankYouBankruptBusinessLogic.OfficePackage.Implements +{ + public class SaveToExcelCashier : AbstractSaveToExcelCashier + { + protected override void CreateExcel(ExcelInfo info) + { + throw new NotImplementedException(); + } + + protected override void InsertCellInWorksheet(ExcelCellParameters excelParams) + { + throw new NotImplementedException(); + } + + protected override void MergeCells(ExcelMergeParameters excelParams) + { + throw new NotImplementedException(); + } + + protected override void SaveExcel(ExcelInfo info) + { + throw new NotImplementedException(); + } + } +} diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/Implements/SaveToWordCashier.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/Implements/SaveToWordCashier.cs new file mode 100644 index 0000000..19655b9 --- /dev/null +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/Implements/SaveToWordCashier.cs @@ -0,0 +1,27 @@ +using BankYouBankruptBusinessLogic.OfficePackage.HelperModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankYouBankruptBusinessLogic.OfficePackage.Implements +{ + public class SaveToWordCashier : AbstractSaveToWordCashier + { + protected override void CreateParagraph(WordParagraph paragraph) + { + throw new NotImplementedException(); + } + + protected override void CreateWord(WordInfo info) + { + throw new NotImplementedException(); + } + + protected override void SaveWord(WordInfo info) + { + throw new NotImplementedException(); + } + } +} diff --git a/BankYouBankrupt/BankYouBankruptCashierApp/Controllers/HomeController.cs b/BankYouBankrupt/BankYouBankruptCashierApp/Controllers/HomeController.cs index 9f1f207..06debf5 100644 --- a/BankYouBankrupt/BankYouBankruptCashierApp/Controllers/HomeController.cs +++ b/BankYouBankrupt/BankYouBankruptCashierApp/Controllers/HomeController.cs @@ -202,44 +202,6 @@ namespace BankYouBankruptCashierApp.Controllers Response.Redirect("Index"); } - //открытие формы отчёта. Получаем и передаём список изделий во вьюху? - [HttpGet] - public IActionResult CreateReport() - { - if (APICashier.Cashier == null) - { - return Redirect("~/Home/Enter"); - } - - ViewBag.Accountes = APICashier.GetRequest>("api/main/getaccountlist"); - - return View(); - } - - //создание отчёта Post-запросом - [HttpPost] - public void CreateReport(DateTime DateFrom, DateTime DateTo) - { - if (APICashier.Cashier == null) - { - throw new Exception("Вы как сюда попали? Суда вход только авторизованным"); - } - - if (DateFrom > DateTo) - { - throw new Exception("Дата начала периода не может быть позже даты конца периода"); - } - - APICashier.PostRequest("api/main/createreport", new ReportBindingModel - { - FileName = APICashier.Cashier.Surname - - //TODO - }); - - Response.Redirect("Index"); - } - //для страницы "Заявки на снятие" [HttpGet] public IActionResult Debiting() @@ -460,5 +422,35 @@ namespace BankYouBankruptCashierApp.Controllers return View(); } - } + + #region Получение отчёта PDF + + [HttpGet] + public IActionResult CreateReport() + { + if (APICashier.Cashier == null) + { + return Redirect("~/Home/Enter"); + } + + return View(); + } + + [HttpPost] + public void CreateReport(DateTime dateFrom, DateTime dateTo) + { + if (APICashier.Cashier == null) + { + throw new Exception("Не авторизованы"); + } + + APICashier.PostRequest("api/Report/CreateCashierReport", new ReportSupportBindingModel() + { + DateFrom = dateFrom, + DateTo = dateTo + }); + } + + #endregion + } } \ No newline at end of file diff --git a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CreateReport.cshtml b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CreateReport.cshtml index c00de4a..59638ae 100644 --- a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CreateReport.cshtml +++ b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CreateReport.cshtml @@ -2,6 +2,34 @@ ViewData["Title"] = "Создание отчёта"; } +
+

Отчёт по счетам за выбранный период

+
+
+
+
Дата начала периода:
+
+ +
+
+
+
Дата конца периода:
+
+ +
+
+
+
+
+ +
+
+
+ + \ No newline at end of file diff --git a/BankYouBankrupt/BankYouBankruptContracts/ViewModels/ReportCashierViewModel.cs b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/ReportCashierViewModel.cs index b02984e..4fd210c 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/ViewModels/ReportCashierViewModel.cs +++ b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/ReportCashierViewModel.cs @@ -8,9 +8,14 @@ namespace BankYouBankruptContracts.ViewModels { public class ReportCashierViewModel { - public int AccountPayeeId { get; set; } - public int? AccountSenderId { get; set; } + public int OperationId { get; set; } + + public int DebitingId { get; set; } + + public string AccountPayeeNumber { get; set; } + + public string? AccountSenderNumber { get; set; } public double SumOperation { get; set; } diff --git a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/CashWithdrawalStorage.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/CashWithdrawalStorage.cs index 70d2f92..99f0e9c 100644 --- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/CashWithdrawalStorage.cs +++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/CashWithdrawalStorage.cs @@ -21,6 +21,7 @@ namespace BankYouBankruptDatabaseImplement.Implements return context.CashWithdrawals .Include(x => x.Cashier) .Include(x => x.Debiting) + .Include(x => x.Account) .Select(x => x.GetViewModel) .ToList(); } @@ -39,14 +40,27 @@ namespace BankYouBankruptDatabaseImplement.Implements return context.CashWithdrawals .Include(x => x.Cashier) .Include(x => x.Debiting) + .Include(x => x.Account) .Where(x => x.CashierId == model.CashierId) .Select(x => x.GetViewModel) .ToList(); } + if(model.DateFrom.HasValue && model.DateTo.HasValue) + { + return context.CashWithdrawals + .Include(x => x.Cashier) + .Include(x => x.Debiting) + .Include(x => x.Account) + .Where(x => x.DateOperation >= model.DateFrom && x.DateOperation <= model.DateTo) + .Select(x => x.GetViewModel) + .ToList(); + } + return context.CashWithdrawals .Include(x => x.Cashier) .Include(x => x.Debiting) + .Include(x => x.Account) .Where(x => x.AccountId == model.AccountId) .Select(x => x.GetViewModel) .ToList(); @@ -64,6 +78,7 @@ namespace BankYouBankruptDatabaseImplement.Implements return context.CashWithdrawals .Include(x => x.Cashier) .Include(x => x.Debiting) + .Include(x => x.Account) .FirstOrDefault(x => (!(model.AccountId < 0) && x.AccountId == model.AccountId) || (model.Id.HasValue && x.Id == model.Id)) ?.GetViewModel; diff --git a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/MoneyTransferStorage.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/MoneyTransferStorage.cs index 693bf2e..e9940ce 100644 --- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/MoneyTransferStorage.cs +++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/MoneyTransferStorage.cs @@ -35,6 +35,17 @@ namespace BankYouBankruptDatabaseImplement.Implements using var context = new BankYouBancruptDatabase(); + if(model.DateFrom.HasValue && model.DateTo.HasValue) + { + return context.MoneyTransfers + .Include(x => x.AccountPayeer) + .Include(x => x.AccountSender) + .Include(x => x.Cashier) + .Where(x => x.DateOperation >= model.DateFrom && x.DateOperation <= model.DateTo && x.AccountSenderId != null) + .Select(x => x.GetViewModel) + .ToList(); + } + return context.MoneyTransfers .Include(x => x.AccountPayeer) .Include(x => x.AccountSender) diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs index daae94b..0c80b16 100644 --- a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs +++ b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs @@ -19,11 +19,13 @@ namespace BankYouBankruptRestAPI.Controllers private readonly IReportClientLogic _reportClientLogic; - public ReportController(ILogger logger, IReportClientLogic reportClientLogic) + private readonly IReportCashierLogic _reportCashierLogic; + + public ReportController(ILogger logger, IReportClientLogic reportClientLogic, IReportCashierLogic reportCashierLogic) { _logger = logger; _reportClientLogic = reportClientLogic; - //_reportCashierLogic = reportCashierLogic; + _reportCashierLogic = reportCashierLogic; } //метод генерации отчёта за период по картам клиента @@ -45,5 +47,25 @@ namespace BankYouBankruptRestAPI.Controllers throw; } } + + //метод генерации отчёта по всем счетм клиентов + [HttpPost] + public void CreateCashierReport(ReportSupportBindingModel model) + { + try + { + _reportCashierLogic.SaveAccountsToPdfFile(new ReportBindingModel + { + FileName = "Отчёт по счетам за " + DateTime.Now.ToShortDateString() + ".pdf", + DateFrom = model.DateFrom, + DateTo = model.DateTo + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка входа в систему"); + throw; + } + } } } diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Program.cs b/BankYouBankrupt/BankYouBankruptRestAPI/Program.cs index ebf2cd2..c3c2cd3 100644 --- a/BankYouBankrupt/BankYouBankruptRestAPI/Program.cs +++ b/BankYouBankrupt/BankYouBankruptRestAPI/Program.cs @@ -32,10 +32,15 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); + +//теперь общий builder.Services.AddTransient(); + builder.Services.AddTransient(); builder.Services.AddTransient(); -//builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddControllers(); diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт по картам за 18.05.2023.pdf b/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт по картам за 18.05.2023.pdf deleted file mode 100644 index 97b5aee..0000000 Binary files a/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт по картам за 18.05.2023.pdf and /dev/null differ