From 26bc87fda9d519759a7172bff412dcf77b0500e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B3=D0=BE=D1=80=D1=8C=20=D0=93=D0=BE=D1=80=D0=B4?= =?UTF-8?q?=D0=B5=D0=B5=D0=B2?= <89176335310x@gmail.com> Date: Fri, 31 May 2024 23:00:26 +0400 Subject: [PATCH] =?UTF-8?q?=D0=AF=20=D1=84=D1=83=D1=82=D0=B1=D0=BE=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D1=8B=D0=B9=20=D0=BC=D1=8F=D1=87=D0=B8=D0=BA,=20?= =?UTF-8?q?=D0=B1=D0=B5=20=D0=B1=D0=B5=20=D0=B1=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogic/ReportClientLogic.cs | 58 +++++++++++++++++++ .../OfficePackage/AbstractSaveToWordClient.cs | 49 ++++++++++------ .../HelperModels/ExcelInfoClient.cs | 2 +- .../HelperModels/WordInfoClient.cs | 2 +- .../IReportClientLogic.cs | 6 +- .../Controllers/ClientController.cs | 30 +++++++++- .../Controllers/EmployeeController.cs | 31 +++++++++- .../Controllers/MainController.cs | 19 +++++- .../Controllers/HomeController.cs | 19 ++++-- .../Views/Home/Message.cshtml | 3 +- .../Views/Home/Report.cshtml | 32 ++++++++++ .../Views/Shared/_Layout.cshtml | 5 +- 12 files changed, 222 insertions(+), 34 deletions(-) create mode 100644 ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportClientLogic.cs create mode 100644 ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/Report.cshtml diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportClientLogic.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportClientLogic.cs new file mode 100644 index 0000000..29b2582 --- /dev/null +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportClientLogic.cs @@ -0,0 +1,58 @@ +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 + { + PaymeantName = paymeant.ID.ToString(), + //PaymeantsList= + }; + } + 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/OfficePackage/AbstractSaveToWordClient.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToWordClient.cs index 7821c34..da69858 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,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); } 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/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/ElectronicsShopContracts/BusinessLogicContracts/IReportClientLogic.cs b/ElectronicsShop/ElectronicsShopContracts/BusinessLogicContracts/IReportClientLogic.cs index 4132e7f..7e439a4 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/ElectronicsShopRestAPI/Controllers/ClientController.cs b/ElectronicsShop/ElectronicsShopRestAPI/Controllers/ClientController.cs index 8ddf38f..10cf5b4 100644 --- a/ElectronicsShop/ElectronicsShopRestAPI/Controllers/ClientController.cs +++ b/ElectronicsShop/ElectronicsShopRestAPI/Controllers/ClientController.cs @@ -13,10 +13,12 @@ namespace ElectronicsShopRestAPI.Controllers { private readonly ILogger _logger; private readonly IClientLogic _logic; + private readonly IReportClientLogic _report; - public ClientController(ILogger logger, IClientLogic logic) { + public ClientController(ILogger logger, IClientLogic logic, IReportClientLogic reportClientLogic) { _logger = logger; _logic = logic; + _report = reportClientLogic; } [HttpGet] @@ -54,5 +56,29 @@ namespace ElectronicsShopRestAPI.Controllers { throw; } } - } + [HttpPost] + public void CreateServiceListWordFile(ReportPaymeantBindingModel model) + { + try + { + _report.SavePaymeantToWordFile(model); + } + catch (Exception ex) + { + throw; + } + } + [HttpPost] + public void CreateServiceListExcelFile(ReportPaymeantBindingModel model) + { + try + { + _report.SavePaymeantToExcelFile(model); + } + catch (Exception ex) + { + throw; + } + } + } } diff --git a/ElectronicsShop/ElectronicsShopRestAPI/Controllers/EmployeeController.cs b/ElectronicsShop/ElectronicsShopRestAPI/Controllers/EmployeeController.cs index d1e15b4..5098225 100644 --- a/ElectronicsShop/ElectronicsShopRestAPI/Controllers/EmployeeController.cs +++ b/ElectronicsShop/ElectronicsShopRestAPI/Controllers/EmployeeController.cs @@ -16,12 +16,15 @@ namespace ElectronicsShopRestAPI.Controllers { private readonly IEmployeeLogic _logic; private readonly ICostItemLogic _costItem; private readonly IProductLogic _productLogic; + private readonly IReportEmployeeLogic _report; - public EmployeeController(ILogger logger, IEmployeeLogic logic, ICostItemLogic costItem, IProductLogic productLogic) { + public EmployeeController(ILogger logger, IEmployeeLogic logic, ICostItemLogic costItem, + IProductLogic productLogic, IReportEmployeeLogic reportEmployeeLogic) { _logger = logger; _logic = logic; _costItem = costItem; _productLogic = productLogic; + _report = reportEmployeeLogic; } [HttpGet] @@ -147,5 +150,29 @@ namespace ElectronicsShopRestAPI.Controllers { throw; } } - } + [HttpPost] + public void CreateServiceListWordFile(ReportProductBindingModel model) + { + try + { + _report.SaveRoutesToWordFile(model); + } + catch (Exception ex) + { + throw; + } + } + [HttpPost] + public void CreateServiceListExcelFile(ReportProductBindingModel model) + { + try + { + _report.SaveRoutesToExcelFile(model); + } + catch (Exception ex) + { + throw; + } + } + } } diff --git a/ElectronicsShop/ElectronicsShopRestAPI/Controllers/MainController.cs b/ElectronicsShop/ElectronicsShopRestAPI/Controllers/MainController.cs index 88a33cf..26382c0 100644 --- a/ElectronicsShop/ElectronicsShopRestAPI/Controllers/MainController.cs +++ b/ElectronicsShop/ElectronicsShopRestAPI/Controllers/MainController.cs @@ -20,6 +20,7 @@ namespace ElectronicsShopRestAPI.Controllers { private readonly IOrderLogic _order; private readonly IMessageInfoLogic _message; + private Dictionary _productlist; public MainController(ILogger logger, IProductLogic product, @@ -159,5 +160,21 @@ namespace ElectronicsShopRestAPI.Controllers { throw; } } - } + [HttpGet] + public List? GetReportClient(int _clientID) + { + try + { + return null;/* + { + + });*/ + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка заказов клиента id = {Id} ", _clientID); + throw; + } + } + } } diff --git a/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs b/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs index 3ef23d6..51077df 100644 --- a/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs +++ b/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs @@ -15,11 +15,9 @@ namespace ElectronicsShopUserApp.Controllers { public class HomeController : Controller { private readonly ILogger _logger; private Dictionary _productList; - //private readonly IOrderLogic _order; - public HomeController(ILogger logger/*, IOrderLogic orderLogic*/) { + public HomeController(ILogger logger) { _logger = logger; - //_order = orderLogic; _productList = new Dictionary(); } @@ -164,5 +162,18 @@ 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/Home/Report.cshtml b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/Report.cshtml new file mode 100644 index 0000000..f3248f5 --- /dev/null +++ b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/Report.cshtml @@ -0,0 +1,32 @@ +@{ + ViewData["Title"] = "Report"; +} + +
+

Отчёты

+
+ +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ + 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 @@ Корзины +