CourseWorkElectronicsShop/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportClientLogic.cs

59 lines
2.2 KiB
C#
Raw Normal View History

2024-06-01 02:22:36 +04:00
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;
2024-06-01 05:27:52 +04:00
_paymeantstorage = paymeantStorage;
2024-06-01 02:22:36 +04:00
}
public List<ReportPaymeantsViewModel> GetPaymeants(ReportBindingModel model)
{
2024-06-06 17:21:39 +04:00
return _paymeantstorage.GetFillteredList(new PaymeantSearchModel {
DateFrom = model.DateFrom,
DateTo = model.DateTo
}).Select(x => new ReportPaymeantsViewModel {
ID = x.ID,
DatePaymeant = x.DatePaymeant,
OrderID = x.OrderID,
ClientID = x.ClientID,
SumPayment = x.SumPayment,
PayOption = x.PayOption,
}).ToList();
2024-06-01 02:22:36 +04:00
}
public void SavePaymeantToExcelFile(ReportBindingModel model)
{
_saveToExcel.CreateReport(new ExcelInfoClient
{
2024-06-06 17:21:39 +04:00
//FileName = model.ProductName,
2024-06-01 02:22:36 +04:00
Title = "Список оплат",
Paymeants = _paymeantstorage.GetFullList(),
});
}
public void SavePaymeantToWordFile(ReportBindingModel model)
{
_saveToWord.CreateDoc(new WordInfoClient
{
2024-06-06 17:21:39 +04:00
//FileName = model.ProductName,
2024-06-01 02:22:36 +04:00
Title = "Список оплат",
ListPaymeant = _paymeantstorage.GetFullList(),
}) ;
}
}
}