CourseWorkElectronicsShop/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportClientLogic.cs

63 lines
2.3 KiB
C#
Raw Permalink 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)
{
var paymeants = _paymeantstorage.GetFullList();
var list = new List<ReportPaymeantsViewModel>();
foreach(var paymeant in paymeants)
{
var record = new ReportPaymeantsViewModel
{
PaymeantID=paymeant.ID,
2024-06-01 05:50:49 +04:00
ClientID=paymeant.ClientID,
2024-06-01 02:22:36 +04:00
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(),
}) ;
}
}
}