А может ну его на фиг

This commit is contained in:
Игорь Гордеев 2024-06-01 01:37:24 +04:00
parent 6c04fe617a
commit 615fbac791
4 changed files with 145 additions and 18 deletions

View File

@ -0,0 +1,62 @@
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(),
}) ;
}
}
}

View File

@ -0,0 +1,50 @@
using ElectronicsShopBusinessLogic.OfficePackage;
using ElectronicsShopBusinessLogic.OfficePackage.HelperModels;
using ElectronicsShopContracts.BindingModels;
using ElectronicsShopContracts.BusinessLogicContracts;
using ElectronicsShopContracts.StorageContracts;
using ElectronicsShopContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopBusinessLogic.BusinessLogic
{
public class ReportEmployeeLogic : IReportEmployeeLogic
{
private readonly IProductStorage _productStorage;
private readonly AbstractSaveToWordEmployee _saveToWord;
private readonly AbstractSaveToExcelEmployee _saveToExcel;
public ReportEmployeeLogic(AbstractSaveToExcelEmployee abstractSaveToExcelEmployee, AbstractSaveToWordEmployee abstractSaveToWordEmployee, IProductStorage productStorage) {
_productStorage = productStorage;
_saveToExcel = abstractSaveToExcelEmployee;
_saveToWord = abstractSaveToWordEmployee;
}
public List<ReportProductsViewModel> GetProduct(ReportProductBindingModel model)
{
throw new NotImplementedException();
}
public void SaveProductsToExcelFile(ReportProductBindingModel model)
{
_saveToExcel.CreateReport(new ExcelInfoEmployee
{
FileName = model.FileName,
Title = "Список продуктов",
Products = _productStorage.GetFullList(),
});
}
public void SaveProductsToWordFile(ReportProductBindingModel model)
{
_saveToWord.CreateDoc(new WordInfoEmployee
{
FileName = model.FileName,
Title = "Список продуктов",
ListProduct = _productStorage.GetFullList()
});
}
}
}

View File

@ -29,7 +29,7 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)>
{ (pre.PaymeantName, new WordTextProperties { Size = "24", Bold=true})},
{ (pre.OrderID.ToString(), new WordTextProperties { Size = "24", Bold=true})},
TextProperties = new WordTextProperties
{
Size = "24",
@ -37,22 +37,37 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
}
});
foreach (var route in pre.PaymeantsList)
{
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)>
{ (route.PayOption.ToString(), new WordTextProperties { Size = "20", Bold=false})},
TextProperties = new WordTextProperties
{
Size = "24",
JustificationType = WordJustificationType.Both
}
});
//Вот тут явно этого будет не хватать, но пока пусть будет только статуст
//Это AbstractSaveToWordClient
}
}
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)>
{ (pre.PayOption.ToString(), new WordTextProperties { Size = "20", Bold=false})},
TextProperties = new WordTextProperties
{
Size = "24",
JustificationType = WordJustificationType.Both
}
});
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)>
{ (pre.ProductID.ToString(), new WordTextProperties { Size = "20", Bold=false})},
TextProperties = new WordTextProperties
{
Size = "24",
JustificationType = WordJustificationType.Both
}
});
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)>
{ (pre.SumPayment.ToString(), new WordTextProperties { Size = "20", Bold=false})},
TextProperties = new WordTextProperties
{
Size = "24",
JustificationType = WordJustificationType.Both
}
});
}
SaveWord(info);
}

View File

@ -8,6 +8,6 @@ namespace ElectronicsShopBusinessLogic.OfficePackage.HelperModels
public string Title { get; set; } = string.Empty;
public List<ReportPaymeantsViewModel> Paymeants { get; set; } = new();
public List<PaymeantViewModel> Paymeants { get; set; } = new();
}
}