From aef701ae24e24b18bbac30014dfdbb3388704490 Mon Sep 17 00:00:00 2001 From: devil_1nc Date: Sat, 2 Dec 2023 01:30:33 +0400 Subject: [PATCH] =?UTF-8?q?=D1=82=D0=B0=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogics/OrderLogic.cs | 4 +- .../BusinessLogics/SupplyLogic.cs | 31 +------- .../ComputerShopRestApi/Program.cs | 2 + .../Controllers/HomeController.cs | 75 +++++++++---------- .../Views/Home/AddAssemblyToOrder.cshtml | 28 +++++++ .../Views/Home/CreateOrder.cshtml | 21 ++++-- .../Views/Home/CreateReceiving.cshtml | 5 -- .../OrdererClientApp/Views/Home/Index.cshtml | 4 +- .../OrdererClientApp/Views/Home/Order.cshtml | 12 ++- 9 files changed, 90 insertions(+), 92 deletions(-) create mode 100644 ComputerShopProvider/OrdererClientApp/Views/Home/AddAssemblyToOrder.cshtml delete mode 100644 ComputerShopProvider/OrdererClientApp/Views/Home/CreateReceiving.cshtml diff --git a/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/OrderLogic.cs b/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/OrderLogic.cs index 453972a..b8f1ea1 100644 --- a/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/OrderLogic.cs +++ b/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/OrderLogic.cs @@ -18,13 +18,11 @@ namespace ComputerShopBusinessLogic.BusinessLogics private readonly ILogger _logger; private readonly IOrderStorage _orderStorage; private readonly IAssemblyStorage _assemblyStorage; - private readonly ISupplyStorage _supplyStorage; - public OrderLogic(ILogger logger, IOrderStorage orderStorage, IAssemblyStorage assemblyStorage, ISupplyStorage supplyStorage) + public OrderLogic(ILogger logger, IOrderStorage orderStorage, IAssemblyStorage assemblyStorage) { _logger = logger; _orderStorage = orderStorage; _assemblyStorage = assemblyStorage; - _supplyStorage = supplyStorage; } public bool CreateOrder(OrderBindingModel model) { diff --git a/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/SupplyLogic.cs b/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/SupplyLogic.cs index 19ab6d2..b23a609 100644 --- a/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/SupplyLogic.cs +++ b/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/SupplyLogic.cs @@ -18,14 +18,12 @@ namespace ComputerShopBusinessLogic.BusinessLogics private readonly ILogger _logger; private readonly ISupplyStorage _supplyStorage; private readonly IOrderStorage _orderStorage; - private readonly IComponentStorage _componentStorage; - public SupplyLogic(ILogger logger, ISupplyStorage supplyStorage, IOrderStorage orderStorage, IComponentStorage componentStorage) + public SupplyLogic(ILogger logger, ISupplyStorage supplyStorage, IOrderStorage orderStorage) { _logger = logger; _supplyStorage = supplyStorage; _orderStorage = orderStorage; - _componentStorage = componentStorage; } public bool Create(SupplyBindingModel model) { @@ -142,31 +140,6 @@ namespace ComputerShopBusinessLogic.BusinessLogics }); return true; - } - public bool AddComponent(SupplySearchModel supplymodel, ComponentSearchModel model) - { - if (model == null) - { - throw new ArgumentNullException(nameof(model)); - } - - var component = _componentStorage.GetElement(model); - var supply = _supplyStorage.GetElement(supplymodel); - - if (component == null || supply == null) - { - return false; - } - - supply.SupplyComponents[supply.Id] = component; - - _supplyStorage.Update(new() - { - Id = supply.Id, - SupplyOrders = supply.SupplyOrders, - }); - - return true; - } + } } } diff --git a/ComputerShopProvider/ComputerShopRestApi/Program.cs b/ComputerShopProvider/ComputerShopRestApi/Program.cs index c42d32e..58e0de1 100644 --- a/ComputerShopProvider/ComputerShopRestApi/Program.cs +++ b/ComputerShopProvider/ComputerShopRestApi/Program.cs @@ -29,9 +29,11 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddTransient(); + builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); diff --git a/ComputerShopProvider/OrdererClientApp/Controllers/HomeController.cs b/ComputerShopProvider/OrdererClientApp/Controllers/HomeController.cs index 8d7f271..d5f15cb 100644 --- a/ComputerShopProvider/OrdererClientApp/Controllers/HomeController.cs +++ b/ComputerShopProvider/OrdererClientApp/Controllers/HomeController.cs @@ -1,4 +1,5 @@ using ComputerShopContracts.BindingModels; +using ComputerShopContracts.SearchModels; using ComputerShopContracts.ViewModels; using DocumentFormat.OpenXml.Office2010.Excel; using Microsoft.AspNetCore.Mvc; @@ -30,9 +31,9 @@ namespace OrdererClientApp.Controllers { if (APIClient.Client == null) { - return Redirect("~/Home/Enter"); + return Redirect("~/Order/Enter"); } - return View(APIClient.GetRequest>($"api/component/order")); + return View(APIClient.GetRequest>($"api/order/getorderlist?clientId={APIClient.Client.Id}")); } public IActionResult Supply() { @@ -128,8 +129,8 @@ namespace OrdererClientApp.Controllers return; } - [HttpGet] - public IActionResult CreateReceiving() + [HttpPost] + public void CreateReceiving() { if (APIClient.Client == null) @@ -142,7 +143,6 @@ namespace OrdererClientApp.Controllers ClientId = APIClient.Client.Id }); Response.Redirect("Index"); - return View(); } [HttpPost] @@ -208,42 +208,37 @@ namespace OrdererClientApp.Controllers Response.Redirect("Index"); } - [HttpGet] - public IActionResult CreateAssembly() + public IActionResult AddAssemblyToOrder() + { + if (APIClient.Client == null) + { + return Redirect("~/Home/Enter"); + } + ViewBag.Assemblies = APIClient.GetRequest>($"api/order/getorderlist?clientId={APIClient.Client.Id}"); + ViewBag.Components = APIClient.GetRequest>($"api/assembly/getassemblylist?clientId={APIClient.Client.Id}"); + return View(); + } + + [HttpPost] + public void AddAssemblyToOrder(int order, int assembly, int amount) + { + if (APIClient.Client == null) + { + throw new Exception("Необходима авторизация"); + } + APIClient.PostRequest("api/order/AddAssemblyToOrder", Tuple.Create( + new AssemblySearchModel() { Id = assembly }, + new OrderSearchModel() { Id = order }, + + amount + )); + + } + + [HttpPost] + public double Calc(int count, int assembly) { - ViewBag.Components = APIClient.GetRequest>("api/component/getcomponentlist"); - ViewBag.CurrentComponents = new List(); - return View(); - } - - [HttpPost] - public void CreateAssembly(string name, int sum) - { - if (APIClient.Client == null) - { - throw new Exception("Вы как суда попали? Суда вход только авторизованным"); - } - if (sum <= 0) - { - throw new Exception("Сумма должна быть больше 0"); - } - APIClient.PostRequest("api/assembly/createassembly", new AssemblyBindingModel - { - ClientId = APIClient.Client.Id, - AssemblyName = name, - Price = 0, - AssemblyComponents = new() - }); - System.Diagnostics.Debug.WriteLine("it might work"); - Response.Redirect("Index"); - } - - - - [HttpPost] - public double Calc(int count, int order) - { - var or = APIClient.GetRequest($"api/main/getcomponent?componentId={order}"); + var or = APIClient.GetRequest($"api/main/getassembly?assemblyId={assembly}"); return count * (or?.Sum ?? 1); } } diff --git a/ComputerShopProvider/OrdererClientApp/Views/Home/AddAssemblyToOrder.cshtml b/ComputerShopProvider/OrdererClientApp/Views/Home/AddAssemblyToOrder.cshtml new file mode 100644 index 0000000..feb5829 --- /dev/null +++ b/ComputerShopProvider/OrdererClientApp/Views/Home/AddAssemblyToOrder.cshtml @@ -0,0 +1,28 @@ +g ComputerShopContracts.ViewModels; +@using ComputerShopDataModels.Models; + +@{ + ViewData["Title"] = "Add Assembly To Order"; +} + +@model Dictionary + +
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+
+
\ No newline at end of file diff --git a/ComputerShopProvider/OrdererClientApp/Views/Home/CreateOrder.cshtml b/ComputerShopProvider/OrdererClientApp/Views/Home/CreateOrder.cshtml index 1627d16..a8e7719 100644 --- a/ComputerShopProvider/OrdererClientApp/Views/Home/CreateOrder.cshtml +++ b/ComputerShopProvider/OrdererClientApp/Views/Home/CreateOrder.cshtml @@ -1,17 +1,24 @@ -@{ +@using ComputerShopContracts.ViewModels; +@using ComputerShopDataModels.Models; + +@{ ViewData["Title"] = "CreateOrder"; } +@model Dictionary +

Создание заказа

-
-
Сумма:
-
+
+ +
+ +
-
-
Цена:
-
+
+
+
diff --git a/ComputerShopProvider/OrdererClientApp/Views/Home/CreateReceiving.cshtml b/ComputerShopProvider/OrdererClientApp/Views/Home/CreateReceiving.cshtml deleted file mode 100644 index e1dd794..0000000 --- a/ComputerShopProvider/OrdererClientApp/Views/Home/CreateReceiving.cshtml +++ /dev/null @@ -1,5 +0,0 @@ -@* - For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 -*@ -@{ -} diff --git a/ComputerShopProvider/OrdererClientApp/Views/Home/Index.cshtml b/ComputerShopProvider/OrdererClientApp/Views/Home/Index.cshtml index 0658bc1..24f36ab 100644 --- a/ComputerShopProvider/OrdererClientApp/Views/Home/Index.cshtml +++ b/ComputerShopProvider/OrdererClientApp/Views/Home/Index.cshtml @@ -20,7 +20,9 @@ }

- Создать новое получение + + +

diff --git a/ComputerShopProvider/OrdererClientApp/Views/Home/Order.cshtml b/ComputerShopProvider/OrdererClientApp/Views/Home/Order.cshtml index 57e780c..18bf67c 100644 --- a/ComputerShopProvider/OrdererClientApp/Views/Home/Order.cshtml +++ b/ComputerShopProvider/OrdererClientApp/Views/Home/Order.cshtml @@ -20,14 +20,12 @@ }

- Создать заказ + Создать заказ

- Изменить заказ -

-

- Удалить заказ + Добавить сборки к заказу

+
@@ -60,10 +58,10 @@
@Html.DisplayFor(modelItem => item.Status) - @Html.DisplayFor(modelItem => item.DateCreate) - @Html.DisplayFor(modelItem => item.DateImplement)