diff --git a/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/PurchaseLogic.cs b/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/PurchaseLogic.cs index c71bbda..e6842af 100644 --- a/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/PurchaseLogic.cs +++ b/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/PurchaseLogic.cs @@ -61,17 +61,17 @@ namespace ComputerShopBusinessLogic.BusinessLogics return true; } - public bool TakeOrderInWork(PurchaseBindingModel model) + public bool TakePurchaseInWork(PurchaseBindingModel model) { return StatusUpdate(model, PurchaseStatus.Выполняется); } - public bool DeliveryOrder(PurchaseBindingModel model) + public bool DeliveryPurchase(PurchaseBindingModel model) { return StatusUpdate(model, PurchaseStatus.Готов); } - public bool FinishOrder(PurchaseBindingModel model) + public bool FinishPurchase(PurchaseBindingModel model) { return StatusUpdate(model, PurchaseStatus.Выдан); } diff --git a/ComputerShopProvider/ComputerShopClientApp/Controllers/HomeController.cs b/ComputerShopProvider/ComputerShopClientApp/Controllers/HomeController.cs index fa45810..d2ed72a 100644 --- a/ComputerShopProvider/ComputerShopClientApp/Controllers/HomeController.cs +++ b/ComputerShopProvider/ComputerShopClientApp/Controllers/HomeController.cs @@ -24,6 +24,15 @@ namespace ComputerShopClientApp.Controllers return View(APIClient.GetRequest>($"api/main/getpurchases?clientId={APIClient.Client.Id}")); } + public IActionResult Component() + { + if (APIClient.Client == null) + { + return Redirect("~/Home/Enter"); + } + return View(APIClient.GetRequest>($"api/component/getcomponentlist")); + } + [HttpGet] public IActionResult Privacy() { @@ -110,14 +119,14 @@ namespace ComputerShopClientApp.Controllers } [HttpGet] - public IActionResult Create() + public IActionResult CreatePurchase() { ViewBag.Components = APIClient.GetRequest>("api/main/getcomponentlist"); return View(); } [HttpPost] - public void Create(int component, int count) + public void CreatePurchase(int component, int count) { if (APIClient.Client == null) { @@ -137,6 +146,33 @@ namespace ComputerShopClientApp.Controllers Response.Redirect("Index"); } + [HttpGet] + public IActionResult CreateComponent() + { + return View(); + } + [HttpPost] + public void CreateComponent(string name, int cost) + { + if (APIClient.Client == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + if (cost <= 0) + { + throw new Exception("Цена должна быть больше 0"); + } + APIClient.PostRequest("api/component/createcomponent", new ComponentBindingModel + { + ClientId = APIClient.Client.Id, + ComponentName = name, + Cost = cost + }); + Response.Redirect("Index"); + } + + + [HttpPost] public double Calc(int count, int component) { diff --git a/ComputerShopProvider/ComputerShopClientApp/Views/Home/Component.cshtml b/ComputerShopProvider/ComputerShopClientApp/Views/Home/Component.cshtml new file mode 100644 index 0000000..32c1348 --- /dev/null +++ b/ComputerShopProvider/ComputerShopClientApp/Views/Home/Component.cshtml @@ -0,0 +1,57 @@ +@using ComputerShopContracts.ViewModels + +@model List + +@{ + ViewData["Title"] = "Component"; +} + +
+

Компоненты

+
+ + +
+ @{ + if (Model == null) + { +

Авторизируйтесь

+ return; + } + +

+ Создать комплектующее +

+ + + + + + + + + + @foreach (var item in Model) + { + + + + + + } + +
+ Номер + + Компонент + + Цена +
+ @Html.DisplayFor(modelItem => item.Id) + + @Html.DisplayFor(modelItem => item.ComponentName) + + @Html.DisplayFor(modelItem => item.Cost) +
+ } +
\ No newline at end of file diff --git a/ComputerShopProvider/ComputerShopClientApp/Views/Home/CreateComponent.cshtml b/ComputerShopProvider/ComputerShopClientApp/Views/Home/CreateComponent.cshtml new file mode 100644 index 0000000..7efb6da --- /dev/null +++ b/ComputerShopProvider/ComputerShopClientApp/Views/Home/CreateComponent.cshtml @@ -0,0 +1,20 @@ +@{ + ViewData["Title"] = "CreateComponent"; +} +
+

Создание комплектующего

+
+
+
+
Название:
+
+
+
+
Цена:
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/ComputerShopProvider/ComputerShopClientApp/Views/Home/Create.cshtml b/ComputerShopProvider/ComputerShopClientApp/Views/Home/CreatePurchase.cshtml similarity index 96% rename from ComputerShopProvider/ComputerShopClientApp/Views/Home/Create.cshtml rename to ComputerShopProvider/ComputerShopClientApp/Views/Home/CreatePurchase.cshtml index bc24881..d5cc322 100644 --- a/ComputerShopProvider/ComputerShopClientApp/Views/Home/Create.cshtml +++ b/ComputerShopProvider/ComputerShopClientApp/Views/Home/CreatePurchase.cshtml @@ -1,5 +1,5 @@ @{ - ViewData["Title"] = "Create"; + ViewData["Title"] = "CreatePurchase"; }

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

diff --git a/ComputerShopProvider/ComputerShopClientApp/Views/Home/Index.cshtml b/ComputerShopProvider/ComputerShopClientApp/Views/Home/Index.cshtml index 19b68ab..7358cc1 100644 --- a/ComputerShopProvider/ComputerShopClientApp/Views/Home/Index.cshtml +++ b/ComputerShopProvider/ComputerShopClientApp/Views/Home/Index.cshtml @@ -20,7 +20,7 @@ }

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

diff --git a/ComputerShopProvider/ComputerShopClientApp/Views/Shared/_Layout.cshtml b/ComputerShopProvider/ComputerShopClientApp/Views/Shared/_Layout.cshtml index 93d7487..103f5c7 100644 --- a/ComputerShopProvider/ComputerShopClientApp/Views/Shared/_Layout.cshtml +++ b/ComputerShopProvider/ComputerShopClientApp/Views/Shared/_Layout.cshtml @@ -13,31 +13,27 @@