From 615fbac79148b93cda5d816d4cc9633f3bfd77dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B3=D0=BE=D1=80=D1=8C=20=D0=93=D0=BE=D1=80=D0=B4?= =?UTF-8?q?=D0=B5=D0=B5=D0=B2?= <89176335310x@gmail.com> Date: Sat, 1 Jun 2024 01:37:24 +0400 Subject: [PATCH] =?UTF-8?q?=D0=90=20=D0=BC=D0=BE=D0=B6=D0=B5=D1=82=20?= =?UTF-8?q?=D0=BD=D1=83=20=D0=B5=D0=B3=D0=BE=20=D0=BD=D0=B0=20=D1=84=D0=B8?= =?UTF-8?q?=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogic/ReportClientLogic.cs | 62 +++++++++++++++++++ .../BusinessLogic/ReportEmployeeLogic.cs | 50 +++++++++++++++ .../OfficePackage/AbstractSaveToWordClient.cs | 49 ++++++++++----- .../HelperModels/ExcelInfoClient.cs | 2 +- 4 files changed, 145 insertions(+), 18 deletions(-) create mode 100644 ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportClientLogic.cs create mode 100644 ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportEmployeeLogic.cs diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportClientLogic.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportClientLogic.cs new file mode 100644 index 0000000..e6bb4c3 --- /dev/null +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportClientLogic.cs @@ -0,0 +1,62 @@ +using ElectronicsShopBusinessLogic.OfficePackage; +using ElectronicsShopBusinessLogic.OfficePackage.HelperModels; +using ElectronicsShopContracts.BindingModels; +using ElectronicsShopContracts.BusinessLogicContracts; +using ElectronicsShopContracts.SearchModels; +using ElectronicsShopContracts.StorageContracts; +using ElectronicsShopContracts.ViewModels; + + +namespace ElectronicsShopBusinessLogic.BusinessLogic +{ + public class ReportClientLogic : IReportClientLogic + { + private readonly IPaymeantStorage _paymeantstorage; + private readonly AbstractSaveToExcelClient _saveToExcel; + private readonly AbstractSaveToWordClient _saveToWord; + + public ReportClientLogic(AbstractSaveToExcelClient abstractSaveToExcelClient, AbstractSaveToWordClient abstractSaveToWordClient, IPaymeantStorage paymeantStorage) { + _saveToExcel = abstractSaveToExcelClient; + _saveToWord= abstractSaveToWordClient; + _paymeantstorage= paymeantStorage; + } + public List GetPaymeants(ReportBindingModel model) + { + var paymeants = _paymeantstorage.GetFullList(); + var list = new List(); + foreach(var paymeant in paymeants) + { + var record = new ReportPaymeantsViewModel + { + PaymeantID=paymeant.ID, + ProductID=paymeant.ProductID, + OrderID=paymeant.OrderID, + PayOption=paymeant.PayOption, + SumPayment=paymeant.SumPayment, + }; + list.Add(record); + } + return list; + } + + public void SavePaymeantToExcelFile(ReportBindingModel model) + { + _saveToExcel.CreateReport(new ExcelInfoClient + { + FileName = model.ProductName, + Title = "Список оплат", + Paymeants = _paymeantstorage.GetFullList(), + }); + } + + public void SavePaymeantToWordFile(ReportBindingModel model) + { + _saveToWord.CreateDoc(new WordInfoClient + { + FileName = model.ProductName, + Title = "Список оплат", + ListPaymeant = _paymeantstorage.GetFullList(), + }) ; + } + } +} diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportEmployeeLogic.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportEmployeeLogic.cs new file mode 100644 index 0000000..e07b8bd --- /dev/null +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportEmployeeLogic.cs @@ -0,0 +1,50 @@ +using ElectronicsShopBusinessLogic.OfficePackage; +using ElectronicsShopBusinessLogic.OfficePackage.HelperModels; +using ElectronicsShopContracts.BindingModels; +using ElectronicsShopContracts.BusinessLogicContracts; +using ElectronicsShopContracts.StorageContracts; +using ElectronicsShopContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ElectronicsShopBusinessLogic.BusinessLogic +{ + public class ReportEmployeeLogic : IReportEmployeeLogic + { + private readonly IProductStorage _productStorage; + private readonly AbstractSaveToWordEmployee _saveToWord; + private readonly AbstractSaveToExcelEmployee _saveToExcel; + public ReportEmployeeLogic(AbstractSaveToExcelEmployee abstractSaveToExcelEmployee, AbstractSaveToWordEmployee abstractSaveToWordEmployee, IProductStorage productStorage) { + _productStorage = productStorage; + _saveToExcel = abstractSaveToExcelEmployee; + _saveToWord = abstractSaveToWordEmployee; + } + public List GetProduct(ReportProductBindingModel model) + { + throw new NotImplementedException(); + } + + public void SaveProductsToExcelFile(ReportProductBindingModel model) + { + _saveToExcel.CreateReport(new ExcelInfoEmployee + { + FileName = model.FileName, + Title = "Список продуктов", + Products = _productStorage.GetFullList(), + }); + } + + public void SaveProductsToWordFile(ReportProductBindingModel model) + { + _saveToWord.CreateDoc(new WordInfoEmployee + { + FileName = model.FileName, + Title = "Список продуктов", + ListProduct = _productStorage.GetFullList() + }); + } + } +} diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToWordClient.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToWordClient.cs index 7821c34..da69858 100644 --- a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToWordClient.cs +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToWordClient.cs @@ -29,7 +29,7 @@ namespace ElectronicsShopBusinessLogic.OfficePackage CreateParagraph(new WordParagraph { Texts = new List<(string, WordTextProperties)> - { (pre.PaymeantName, new WordTextProperties { Size = "24", Bold=true})}, + { (pre.OrderID.ToString(), new WordTextProperties { Size = "24", Bold=true})}, TextProperties = new WordTextProperties { Size = "24", @@ -37,22 +37,37 @@ namespace ElectronicsShopBusinessLogic.OfficePackage } }); - foreach (var route in pre.PaymeantsList) - { - CreateParagraph(new WordParagraph - { - Texts = new List<(string, WordTextProperties)> - { (route.PayOption.ToString(), new WordTextProperties { Size = "20", Bold=false})}, - TextProperties = new WordTextProperties - { - Size = "24", - JustificationType = WordJustificationType.Both - } - }); - //Вот тут явно этого будет не хватать, но пока пусть будет только статуст - //Это AbstractSaveToWordClient - } - } + CreateParagraph(new WordParagraph + { + Texts = new List<(string, WordTextProperties)> + { (pre.PayOption.ToString(), new WordTextProperties { Size = "20", Bold=false})}, + TextProperties = new WordTextProperties + { + Size = "24", + JustificationType = WordJustificationType.Both + } + }); + CreateParagraph(new WordParagraph + { + Texts = new List<(string, WordTextProperties)> + { (pre.ProductID.ToString(), new WordTextProperties { Size = "20", Bold=false})}, + TextProperties = new WordTextProperties + { + Size = "24", + JustificationType = WordJustificationType.Both + } + }); + CreateParagraph(new WordParagraph + { + Texts = new List<(string, WordTextProperties)> + { (pre.SumPayment.ToString(), new WordTextProperties { Size = "20", Bold=false})}, + TextProperties = new WordTextProperties + { + Size = "24", + JustificationType = WordJustificationType.Both + } + }); + } SaveWord(info); } diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/HelperModels/ExcelInfoClient.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/HelperModels/ExcelInfoClient.cs index f2499b6..a2cedde 100644 --- a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/HelperModels/ExcelInfoClient.cs +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/HelperModels/ExcelInfoClient.cs @@ -8,6 +8,6 @@ namespace ElectronicsShopBusinessLogic.OfficePackage.HelperModels public string Title { get; set; } = string.Empty; - public List Paymeants { get; set; } = new(); + public List Paymeants { get; set; } = new(); } }