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(); } }