63 lines
2.3 KiB
C#
63 lines
2.3 KiB
C#
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<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,
|
|
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(),
|
|
}) ;
|
|
}
|
|
}
|
|
}
|