diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportClientLogic.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportClientLogic.cs new file mode 100644 index 0000000..e6bb4c3 --- /dev/null +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportClientLogic.cs @@ -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 GetPaymeants(ReportBindingModel model) + { + var paymeants = _paymeantstorage.GetFullList(); + var list = new List(); + 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(), + }) ; + } + } +} diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportEmployeeLogic.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportEmployeeLogic.cs new file mode 100644 index 0000000..e07b8bd --- /dev/null +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportEmployeeLogic.cs @@ -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 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() + }); + } + } +} diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToExcelClient.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToExcelClient.cs index 9ffdf9d..8b32211 100644 --- a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToExcelClient.cs +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToExcelClient.cs @@ -31,31 +31,25 @@ namespace ElectronicsShopBusinessLogic.OfficePackage { ColumnName = "A", RowIndex = rowIndex, - Text = pc.PaymeantName.ToString(), + Text = pc.OrderID.ToString(), StyleInfo = ExcelStyleInfoType.Text }); rowIndex++; - foreach (var payment in pc.PaymeantsList) + InsertCellInWorksheet(new ExcelCellParameters { - InsertCellInWorksheet(new ExcelCellParameters - { - ColumnName = "B", - RowIndex = rowIndex, - Text = payment.PayOption.ToString(), - StyleInfo = ExcelStyleInfoType.Text - }); - InsertCellInWorksheet(new ExcelCellParameters - { - ColumnName = "C", - RowIndex = rowIndex, - Text = payment.SumPayment.ToString(), - StyleInfo = ExcelStyleInfoType.TextWithBroder - }); - //Не хорошо, что доступны ID а не название продукта, в идеале пофиксить надо - //Это AbstractSaveToExcelClient - rowIndex++; - } + ColumnName = "B", + RowIndex = rowIndex, + Text = pc.PayOption.ToString(), + StyleInfo = ExcelStyleInfoType.Text + }); + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "C", + RowIndex = rowIndex, + Text = pc.SumPayment.ToString(), + StyleInfo = ExcelStyleInfoType.TextWithBroder + }); rowIndex++; } diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToExcelEmployee.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToExcelEmployee.cs index b0c3432..0047ec9 100644 --- a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToExcelEmployee.cs +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToExcelEmployee.cs @@ -36,26 +36,21 @@ namespace ElectronicsShopBusinessLogic.OfficePackage }); rowIndex++; - foreach (var product in pc.Products) + InsertCellInWorksheet(new ExcelCellParameters { - InsertCellInWorksheet(new ExcelCellParameters - { - ColumnName = "B", - RowIndex = rowIndex, - Text = product.ProductName.ToString(), - StyleInfo = ExcelStyleInfoType.TextWithBroder - }); + ColumnName = "B", + RowIndex = rowIndex, + Text = pc.ProductName.ToString(), + StyleInfo = ExcelStyleInfoType.TextWithBroder + }); - InsertCellInWorksheet(new ExcelCellParameters - { - ColumnName = "C", - RowIndex = rowIndex, - Text = product.Price.ToString(), - StyleInfo = ExcelStyleInfoType.TextWithBroder - }); - - rowIndex++; - } + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "C", + RowIndex = rowIndex, + Text = pc.Price.ToString(), + StyleInfo = ExcelStyleInfoType.TextWithBroder + }); rowIndex++; } diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToWordClient.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToWordClient.cs index 7821c34..d390f0a 100644 --- a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToWordClient.cs +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToWordClient.cs @@ -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,17 @@ 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 + } + }); + } SaveWord(info); } diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToWordEmployee.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToWordEmployee.cs index 93914e1..02f281e 100644 --- a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToWordEmployee.cs +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToWordEmployee.cs @@ -37,22 +37,17 @@ namespace ElectronicsShopBusinessLogic.OfficePackage } }); - foreach (var pre in product.Products) - { - CreateParagraph(new WordParagraph - { - Texts = new List<(string, WordTextProperties)> - { (pre.ProductName, new WordTextProperties { Size = "20", Bold=false})}, - TextProperties = new WordTextProperties - { - Size = "24", - JustificationType = WordJustificationType.Both - } - }); - //Добавить ещё поля кроме названия продукта - //Это AbstractSaveToWordEmployee - } - } + CreateParagraph(new WordParagraph + { + Texts = new List<(string, WordTextProperties)> + { (product.ProductName, new WordTextProperties { Size = "20", Bold=false})}, + TextProperties = new WordTextProperties + { + Size = "24", + JustificationType = WordJustificationType.Both + } + }); + } SaveWord(info); } diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/HelperModels/ExcelInfoClient.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/HelperModels/ExcelInfoClient.cs index f2499b6..a2cedde 100644 --- a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/HelperModels/ExcelInfoClient.cs +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/HelperModels/ExcelInfoClient.cs @@ -8,6 +8,6 @@ namespace ElectronicsShopBusinessLogic.OfficePackage.HelperModels public string Title { get; set; } = string.Empty; - public List Paymeants { get; set; } = new(); + public List Paymeants { get; set; } = new(); } } diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/HelperModels/ExcelInfoEmployee.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/HelperModels/ExcelInfoEmployee.cs index 9e5b755..8cca808 100644 --- a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/HelperModels/ExcelInfoEmployee.cs +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/HelperModels/ExcelInfoEmployee.cs @@ -8,6 +8,6 @@ namespace ElectronicsShopBusinessLogic.OfficePackage.HelperModels public string Title { get; set; } = string.Empty; - public List Products { get; set; } = new(); + public List Products { get; set; } = new(); } } diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/HelperModels/WordInfoClient.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/HelperModels/WordInfoClient.cs index 101c841..d1d2430 100644 --- a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/HelperModels/WordInfoClient.cs +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/HelperModels/WordInfoClient.cs @@ -9,6 +9,6 @@ namespace ElectronicsShopBusinessLogic.OfficePackage.HelperModels public string Title { get; set; } = string.Empty; - public List ListPaymeant { get; set; } = new(); + public List ListPaymeant { get; set; } = new(); } } diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/HelperModels/WordInfoEmployee.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/HelperModels/WordInfoEmployee.cs index ff98c64..5956264 100644 --- a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/HelperModels/WordInfoEmployee.cs +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/HelperModels/WordInfoEmployee.cs @@ -9,6 +9,6 @@ namespace ElectronicsShopBusinessLogic.OfficePackage.HelperModels public string Title { get; set; } = string.Empty; - public List ListProduct { get; set; } = new(); + public List ListProduct { get; set; } = new(); } } diff --git a/ElectronicsShop/ElectronicsShopContracts/BusinessLogicContracts/IReportClientLogic.cs b/ElectronicsShop/ElectronicsShopContracts/BusinessLogicContracts/IReportClientLogic.cs index 4132e7f..8937855 100644 --- a/ElectronicsShop/ElectronicsShopContracts/BusinessLogicContracts/IReportClientLogic.cs +++ b/ElectronicsShop/ElectronicsShopContracts/BusinessLogicContracts/IReportClientLogic.cs @@ -10,8 +10,8 @@ namespace ElectronicsShopContracts.BusinessLogicContracts { public interface IReportClientLogic { - List GetPaymeants(ReportPaymeantBindingModel model); - void SavePreservesToWordFile(ReportPaymeantBindingModel model); - void SavePreservesToExcelFile(ReportPaymeantBindingModel model); - } + List GetPaymeants(ReportBindingModel model); + void SavePaymeantToWordFile(ReportBindingModel model); + void SavePaymeantToExcelFile(ReportBindingModel model); + } } diff --git a/ElectronicsShop/ElectronicsShopContracts/BusinessLogicContracts/IReportEmployeeLogic.cs b/ElectronicsShop/ElectronicsShopContracts/BusinessLogicContracts/IReportEmployeeLogic.cs index 4f58760..12ac080 100644 --- a/ElectronicsShop/ElectronicsShopContracts/BusinessLogicContracts/IReportEmployeeLogic.cs +++ b/ElectronicsShop/ElectronicsShopContracts/BusinessLogicContracts/IReportEmployeeLogic.cs @@ -10,8 +10,8 @@ namespace ElectronicsShopContracts.BusinessLogicContracts { public interface IReportEmployeeLogic { - List GetRoute(ReportProductBindingModel model); - void SaveRoutesToWordFile(ReportProductBindingModel model); - void SaveRoutesToExcelFile(ReportProductBindingModel model); - } + List GetProduct(ReportProductBindingModel model); + void SaveProductsToWordFile(ReportProductBindingModel model); + void SaveProductsToExcelFile(ReportProductBindingModel model); + } } diff --git a/ElectronicsShop/ElectronicsShopContracts/ViewModels/ReportPaymeantsViewModel.cs b/ElectronicsShop/ElectronicsShopContracts/ViewModels/ReportPaymeantsViewModel.cs index dca6f74..0c8a943 100644 --- a/ElectronicsShop/ElectronicsShopContracts/ViewModels/ReportPaymeantsViewModel.cs +++ b/ElectronicsShop/ElectronicsShopContracts/ViewModels/ReportPaymeantsViewModel.cs @@ -1,4 +1,5 @@ -using System; +using ElectronicsShopDataModels.Enums; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,7 +9,12 @@ namespace ElectronicsShopContracts.ViewModels { public class ReportPaymeantsViewModel { - public string PaymeantName { get; set; } = string.Empty; - public List PaymeantsList { get; set; } = new(); - } + public int PaymeantID { get; set; } + + public int ProductID { get; set; } + + public int OrderID { get; set; } + public double SumPayment { get; set; } + public PaymeantOption PayOption { get; set; } = PaymeantOption.Неоплачено; + } } diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/DataBase.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/DataBase.cs index 2830f99..247925f 100644 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/DataBase.cs +++ b/ElectronicsShop/ElectronicsShopDataBaseImplement/DataBase.cs @@ -12,7 +12,7 @@ namespace ElectronicsShopDataBaseImplement optionsBuilder) { if (optionsBuilder.IsConfigured == false) { - optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-O0N00SH\SQLEXPRESS;Initial Catalog=ElectronicsShopDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-E2VPEN3\SQLEXPRESS;Initial Catalog=ElectronicsShopDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); } diff --git a/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs b/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs index 6726a78..6b3043f 100644 --- a/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs +++ b/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs @@ -187,5 +187,17 @@ namespace ElectronicsShopUserApp.Controllers { var _product = APIClient.GetRequset($"api/main/getproduct?_productid={product}"); return count * (_product?.Price ?? 1); } - } + [HttpGet] + public IActionResult Report() + { + //ViewBag.Reports = APIClient.GetRequset>($"api/main/getproducts"); + return View(); + } + [HttpGet] + public IActionResult Message() + { + //ViewBag.Reports = APIClient.GetRequset>($"api/main/getproducts"); + return View(); + } + } } diff --git a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/Message.cshtml b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/Message.cshtml index 95e88cc..d5ca5c4 100644 --- a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/Message.cshtml +++ b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/Message.cshtml @@ -6,8 +6,7 @@ }
-

Отчёты

- Создать товар +

Письма

@{ diff --git a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Shared/_Layout.cshtml b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Shared/_Layout.cshtml index c4396f5..a2bd948 100644 --- a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Shared/_Layout.cshtml +++ b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Shared/_Layout.cshtml @@ -35,7 +35,10 @@ Корзины +