Reports logic.

This commit is contained in:
Yuee Shiness 2023-05-19 13:39:54 +04:00
parent 9bd7b98042
commit 6e2912f1c4
4 changed files with 44 additions and 15 deletions

View File

@ -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,14 +22,18 @@ namespace ComputerStoreBusinessLogic.BusinessLogic
private readonly IPCStorage _pcStorage;
private readonly IProductStorage _productStorage;
private readonly IConsignmentStorage _consignmentStorage;
private readonly IOrderStorage _orderStorage;
private readonly AbstractSaveToExcel _saveToExcel;
private readonly AbstractSaveToPDF _saveToPDF;
private readonly AbstractSaveToWord _saveToWord;
public EmployeeReportLogic(IPCStorage pcStorage, IProductStorage productStorage, IConsignmentStorage consignmentStorage, IOrderStorage orderStorage)
public EmployeeReportLogic(IPCStorage pcStorage, IProductStorage productStorage, IConsignmentStorage consignmentStorage, AbstractSaveToPDF saveToPDF, AbstractSaveToWord saveToWord, AbstractSaveToExcel saveToExcel)
{
_pcStorage = pcStorage;
_productStorage = productStorage;
_consignmentStorage = consignmentStorage;
_orderStorage = orderStorage;
_saveToPDF = saveToPDF;
_saveToWord = saveToWord;
_saveToExcel = saveToExcel;
}
public List<ReportPCByDateViewModel> GetPCsByDate(ReportDateBindingModel model)
@ -125,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)
});
}
}
}

View File

@ -17,6 +17,5 @@ namespace ComputerStoreBusinessLogic.OfficePackage.HelperModels
set;
} = new();
}
}

View File

@ -11,6 +11,6 @@ namespace ComputerStoreBusinessLogic.OfficePackage.HelperModels
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public List<ConsignmentViewModel> Consignments { get; set; } = new();
public List<ReportConsignmentsViewModel> Consignments { get; set; } = new();
}
}

View File

@ -14,7 +14,8 @@ namespace ComputerStoreContracts.BusinessLogicContracts
List<ReportPCByDateViewModel> GetPCsByDate(ReportDateBindingModel model);
List<ReportConsignmentsViewModel> GetConsignmentsByComponents(ReportComponentsBindingModel model);
void SaveProductsToPdfFile(ReportDateBindingModel model);
void SavePCsToPdfFile(ReportDateBindingModel model);
void SavePCsAndProductsToPdfFile(ReportDateBindingModel model);
void SaveConsignmentsToExcelFile(ReportComponentsBindingModel model);
void SaveConsignmentsToWordFile(ReportComponentsBindingModel model);
}
}