diff --git a/ComputerStoreBusinessLogic/BusinessLogic/EmployeeReportLogic.cs b/ComputerStoreBusinessLogic/BusinessLogic/EmployeeReportLogic.cs index a417411..75d68c4 100644 --- a/ComputerStoreBusinessLogic/BusinessLogic/EmployeeReportLogic.cs +++ b/ComputerStoreBusinessLogic/BusinessLogic/EmployeeReportLogic.cs @@ -1,9 +1,12 @@ -using ComputerStoreContracts.BindingModels; +using ComputerStoreBusinessLogic.OfficePackage; +using ComputerStoreBusinessLogic.OfficePackage.HelperModels; +using ComputerStoreContracts.BindingModels; using ComputerStoreContracts.BusinessLogicContracts; using ComputerStoreContracts.SearchModels; using ComputerStoreContracts.StorageContracts; using ComputerStoreContracts.ViewModels; using ComputerStoreDataModels.Models; +using MigraDoc.DocumentObjectModel.Fields; using System; using System.Collections.Generic; using System.Linq; @@ -19,12 +22,18 @@ namespace ComputerStoreBusinessLogic.BusinessLogic private readonly IPCStorage _pcStorage; private readonly IProductStorage _productStorage; private readonly IConsignmentStorage _consignmentStorage; - - public EmployeeReportLogic(IPCStorage pcStorage, IProductStorage productStorage, IConsignmentStorage consignmentStorage) + private readonly AbstractSaveToExcel _saveToExcel; + private readonly AbstractSaveToPDF _saveToPDF; + private readonly AbstractSaveToWord _saveToWord; + + public EmployeeReportLogic(IPCStorage pcStorage, IProductStorage productStorage, IConsignmentStorage consignmentStorage, AbstractSaveToPDF saveToPDF, AbstractSaveToWord saveToWord, AbstractSaveToExcel saveToExcel) { _pcStorage = pcStorage; _productStorage = productStorage; _consignmentStorage = consignmentStorage; + _saveToPDF = saveToPDF; + _saveToWord = saveToWord; + _saveToExcel = saveToExcel; } public List GetPCsByDate(ReportDateBindingModel model) @@ -123,16 +132,38 @@ namespace ComputerStoreBusinessLogic.BusinessLogic return list; } - public void SaveProductsToPdfFile(ReportDateBindingModel model) + + public void SavePCsAndProductsToPdfFile(ReportDateBindingModel model) { - //will be implemented in the future! + _saveToPDF.CreateDoc(new PDFInfo + { + FileName = model.FileName, + Title = "Products 'n orders list", + DateFrom = model.DateFrom!.Value, + DateTo = model.DateTo!.Value, + Products = GetProductsByDate(model), + PCs = GetPCsByDate(model) + }); } - public void SavePCsToPdfFile(ReportDateBindingModel model) + public void SaveConsignmentsToExcelFile(ReportComponentsBindingModel model) { - //will be implemented in the future! + _saveToExcel.CreateReport(new ExcelInfo + { + FileName = model.FileName, + Title = "Consignments list", + ConsignmentProducts = GetConsignmentsByComponents(model) + }); } - + public void SaveConsignmentsToWordFile(ReportComponentsBindingModel model) + { + _saveToWord.CreateDoc(new WordInfo + { + FileName = model.FileName, + Title = "Consignments list", + Consignments = GetConsignmentsByComponents(model) + }); + } } } diff --git a/ComputerStoreBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs b/ComputerStoreBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs index 142437f..8670ea7 100644 --- a/ComputerStoreBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs +++ b/ComputerStoreBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs @@ -16,7 +16,6 @@ namespace ComputerStoreBusinessLogic.OfficePackage.HelperModels get; set; } = new(); - - + } } diff --git a/ComputerStoreBusinessLogic/OfficePackage/HelperModels/WordInfo.cs b/ComputerStoreBusinessLogic/OfficePackage/HelperModels/WordInfo.cs index ce9faa3..8557c3c 100644 --- a/ComputerStoreBusinessLogic/OfficePackage/HelperModels/WordInfo.cs +++ b/ComputerStoreBusinessLogic/OfficePackage/HelperModels/WordInfo.cs @@ -11,6 +11,6 @@ namespace ComputerStoreBusinessLogic.OfficePackage.HelperModels { public string FileName { get; set; } = string.Empty; public string Title { get; set; } = string.Empty; - public List Consignments { get; set; } = new(); + public List Consignments { get; set; } = new(); } } diff --git a/ComputerStoreContracts/BusinessLogicContracts/IEmployeeReportLogic.cs b/ComputerStoreContracts/BusinessLogicContracts/IEmployeeReportLogic.cs index d245602..544b698 100644 --- a/ComputerStoreContracts/BusinessLogicContracts/IEmployeeReportLogic.cs +++ b/ComputerStoreContracts/BusinessLogicContracts/IEmployeeReportLogic.cs @@ -14,7 +14,8 @@ namespace ComputerStoreContracts.BusinessLogicContracts List GetPCsByDate(ReportDateBindingModel model); List GetConsignmentsByComponents(ReportComponentsBindingModel model); - void SaveProductsToPdfFile(ReportDateBindingModel model); - void SavePCsToPdfFile(ReportDateBindingModel model); + void SavePCsAndProductsToPdfFile(ReportDateBindingModel model); + void SaveConsignmentsToExcelFile(ReportComponentsBindingModel model); + void SaveConsignmentsToWordFile(ReportComponentsBindingModel model); } }