From b0b76b18dae9f9c04e9aa041427bb29cb5321458 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Tue, 4 Apr 2023 23:22:23 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=BC=D0=B5=D0=B6=D1=83?= =?UTF-8?q?=D1=82=D0=BE=D1=87=D0=BD=D0=BE=D0=B5=20=D1=81=D0=BE=D1=85=D1=80?= =?UTF-8?q?=D0=B0=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BankYouBankruptBusinessLogic.csproj | 4 - .../BusinessLogics/ReportCashierLogic.cs | 107 ++++++++++++++++++ .../OfficePackage/HelperModels/ExcelInfo.cs | 8 +- .../OfficePackage/HelperModels/PdfInfo.cs | 2 +- .../IReportCashierLogic.cs | 8 +- .../SearchModels/MoneyTransferSearchModel.cs | 4 +- 6 files changed, 122 insertions(+), 11 deletions(-) create mode 100644 BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportCashierLogic.cs diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/BankYouBankruptBusinessLogic.csproj b/BankYouBankrupt/BankYouBankruptBusinessLogic/BankYouBankruptBusinessLogic.csproj index 4eea3c3..1fa554a 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/BankYouBankruptBusinessLogic.csproj +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/BankYouBankruptBusinessLogic.csproj @@ -6,10 +6,6 @@ enable - - - - diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportCashierLogic.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportCashierLogic.cs new file mode 100644 index 0000000..15ba804 --- /dev/null +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportCashierLogic.cs @@ -0,0 +1,107 @@ +using BankYouBankruptBusinessLogic.OfficePackage; +using BankYouBankruptBusinessLogic.OfficePackage.HelperModels; +using BankYouBankruptContracts.BindingModels; +using BankYouBankruptContracts.BusinessLogicsContracts; +using BankYouBankruptContracts.SearchModels; +using BankYouBankruptContracts.StoragesContracts; +using BankYouBankruptContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankYouBankruptBusinessLogic.BusinessLogics +{ + public class ReportCashierLogic : IReportCashierLogic + { + private readonly IMoneyTransferStorage _moneyTransferStorage; + + private readonly ICashWithdrawalStorage _cashWithdrawalStorage; + + //private readonly IAccountStorage _accountStorage; + + private readonly AbstractSaveToExcelCashier _saveToExcel; + + private readonly AbstractSaveToWordCashier _saveToWord; + + private readonly AbstractSaveToPdfCashier _saveToPdf; + + //инициализируем поля класса через контейнер + public ReportCashierLogic(IMoneyTransferStorage moneyTransferStorage, ICashWithdrawalStorage cashWithdrawalStorage, + IAccountStorage accountStorage, AbstractSaveToExcelCashier saveToExcel, AbstractSaveToWordCashier saveToWord, + AbstractSaveToPdfCashier saveToPdf) + { + _moneyTransferStorage = moneyTransferStorage; + _cashWithdrawalStorage = cashWithdrawalStorage; + //_accountStorage = accountStorage; + + _saveToExcel = saveToExcel; + _saveToWord = saveToWord; + _saveToPdf = saveToPdf; + } + + public List? GetMoneyTransfers(ReportBindingModel model) + { + return _moneyTransferStorage.GetFilteredList(new MoneyTransferSearchModel { DateOperation = model.DateOperation}) + .Select(x => new ReportCashierViewModel + { + AccountId = x.Id, + DateComplite = x.DateComplite, + ClientName = x.ClientName, + SumOperation = x.SumOperation, + TypeOperation = x.TypeOperation + }) + .ToList(); + } + + public List? GetCashWithrawals(ReportBindingModel model) + { + return _accountStorage.GetFilteredList(new CashWithdrawalSearchModel { DateFrom = model.DateFrom, DateTo = model.DateTo }) + .Select(x => new ReportOrdersViewModel + { + Id = x.Id, + DateCreate = x.DateCreate, + ManufactureName = x.ManufactureName, + Sum = x.Sum, + OrderStatus = x.Status.ToString() + }) + .ToList(); + } + + //Сохранение мороженных в файл-Word + public void SaveAccountsToWordFile(ReportBindingModel model) + { + _saveToWord.CreateDoc(new WordInfo + { + FileName = model.FileName, + Title = "Список изделий", + Accounts = _accountStorage.GetFullList() + }); + } + + //Сохранение заготовок с указаеним изделий в файл-Excel + public void SaveAccountsToExcelFile(ReportBindingModel model) + { + _saveToExcel.CreateReport(new ExcelInfo + { + FileName = model.FileName, + Title = "Список заготовок", + Accounts = _accountStorage.GetFullList() + }); + } + + //Сохранение заказов в файл-Pdf + public void SaveAccountsToPdfFile(ReportBindingModel model) + { + _saveToPdf.CreateDoc(new PdfInfo + { + FileName = model.FileName, + Title = "Список заказов", + DateFrom = model.DateFrom!.Value, + DateTo = model.DateTo!.Value, + ReportAccounts = GetAccounts(model) + }); + } + } +} diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs index 99cbc13..f470675 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs @@ -1,4 +1,5 @@ -using System; +using BankYouBankruptContracts.ViewModels; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -14,5 +15,8 @@ namespace BankYouBankruptBusinessLogic.OfficePackage.HelperModels //заголовок public string Title { get; set; } = string.Empty; - } + + //список счетов для вывода и сохранения + public List Accounts { get; set; } = new(); + } } diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs index e889ddb..f696ce3 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs @@ -19,6 +19,6 @@ namespace BankYouBankruptBusinessLogic.OfficePackage.HelperModels public DateTime DateTo { get; set; } //перечень заказов за указанный период для вывода/сохранения - public List reportAccounts { get; set; } = new(); + public List ReportAccounts { get; set; } = new(); } } diff --git a/BankYouBankrupt/BankYouBankruptContracts/BusinessLogicsContracts/IReportCashierLogic.cs b/BankYouBankrupt/BankYouBankruptContracts/BusinessLogicsContracts/IReportCashierLogic.cs index 8a26c89..b884af5 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/BusinessLogicsContracts/IReportCashierLogic.cs +++ b/BankYouBankrupt/BankYouBankruptContracts/BusinessLogicsContracts/IReportCashierLogic.cs @@ -10,10 +10,12 @@ namespace BankYouBankruptContracts.BusinessLogicsContracts { public interface IReportCashierLogic { - List? GetAccounts(ReportBindingModel model); + List? GetMoneyTransfers(ReportBindingModel model); - //Сохранение отчёта по счетам в файл-Word - void SaveAccountsToWordFile(ReportBindingModel model); + List? GetCashWithrawals(ReportBindingModel model); + + //Сохранение отчёта по счетам в файл-Word + void SaveAccountsToWordFile(ReportBindingModel model); //Сохранение отчёта по счетам в файл-Excel void SaveAccountsToExcelFile(ReportBindingModel model); diff --git a/BankYouBankrupt/BankYouBankruptContracts/SearchModels/MoneyTransferSearchModel.cs b/BankYouBankrupt/BankYouBankruptContracts/SearchModels/MoneyTransferSearchModel.cs index fd1bbcc..84a1109 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/SearchModels/MoneyTransferSearchModel.cs +++ b/BankYouBankrupt/BankYouBankruptContracts/SearchModels/MoneyTransferSearchModel.cs @@ -16,6 +16,8 @@ namespace BankYouBankruptContracts.SearchModels public int? AccountPayeeId { get; set; } - public DateTime? DateOperation { get; set; } + public DateTime? DateFrom { get; set; } + + public DateTime? DateTo { get; set; } } }