From b426a6373da8e1719f91cb772efb6940fd756de0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B9?= Date: Fri, 19 May 2023 14:06:33 +0400 Subject: [PATCH] fix frontend and update user --- .../Views/Storekeeper/ListBuilds.cshtml | 4 +- .../Controllers/HomeController.cs | 35 +++++++- .../Views/Home/Builds.cshtml | 8 +- .../Views/Home/Comments.cshtml | 2 +- .../Views/Home/CreatePurchase.cshtml | 1 - .../Views/Home/LinkPurchase.cshtml | 12 +-- .../Views/Home/Privacy.cshtml | 29 +++++++ .../Views/Home/Purchases.cshtml | 2 +- .../Views/Home/UpdatePurchase.cshtml | 1 - .../Views/Home/WorkerReport.cshtml | 81 +++++-------------- .../Views/Home/listComponents.cshtml | 4 +- .../Views/Shared/_LayoutWorker.cshtml | 3 + 12 files changed, 103 insertions(+), 79 deletions(-) create mode 100644 HardwareShop/HardwareShopWorkerApp/Views/Home/Privacy.cshtml diff --git a/HardwareShop/HardwareShopClientApp/Views/Storekeeper/ListBuilds.cshtml b/HardwareShop/HardwareShopClientApp/Views/Storekeeper/ListBuilds.cshtml index cfc8c7b..c89f385 100644 --- a/HardwareShop/HardwareShopClientApp/Views/Storekeeper/ListBuilds.cshtml +++ b/HardwareShop/HardwareShopClientApp/Views/Storekeeper/ListBuilds.cshtml @@ -24,8 +24,8 @@
- - + +
diff --git a/HardwareShop/HardwareShopWorkerApp/Controllers/HomeController.cs b/HardwareShop/HardwareShopWorkerApp/Controllers/HomeController.cs index 484b7bf..dba2e79 100644 --- a/HardwareShop/HardwareShopWorkerApp/Controllers/HomeController.cs +++ b/HardwareShop/HardwareShopWorkerApp/Controllers/HomeController.cs @@ -1,4 +1,5 @@ -using HardwareShopContracts.BindingModels; +using DocumentFormat.OpenXml.Spreadsheet; +using HardwareShopContracts.BindingModels; using HardwareShopContracts.SearchModels; using HardwareShopContracts.ViewModels; using HardwareShopDatabaseImplement.Models; @@ -56,9 +57,39 @@ namespace HardwareShopWorkerApp.Controllers return View(); } + [HttpGet] public IActionResult Privacy() { - return View(); + if (APIClient.User == null) + { + return Redirect("~/Home/Enter"); + } + return View(APIClient.User); + } + + [HttpPost] + public void Privacy(string login, string email, string password) + { + if (APIClient.User == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) + { + throw new Exception("Введите логин, пароль и ФИО"); + } + APIClient.PostRequest("api/user/updatedata", new UserBindingModel + { + Id = APIClient.User.Id, + Login = login, + Email = email, + Password = password + }); + + APIClient.User.Login = login; + APIClient.User.Email = email; + APIClient.User.Password = password; + Response.Redirect("MainWorker"); } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] diff --git a/HardwareShop/HardwareShopWorkerApp/Views/Home/Builds.cshtml b/HardwareShop/HardwareShopWorkerApp/Views/Home/Builds.cshtml index 7aa0654..785b6bb 100644 --- a/HardwareShop/HardwareShopWorkerApp/Views/Home/Builds.cshtml +++ b/HardwareShop/HardwareShopWorkerApp/Views/Home/Builds.cshtml @@ -15,7 +15,7 @@

Сборки

- +
@@ -49,13 +49,13 @@ @Html.DisplayFor(modelItem => item.BuildName) diff --git a/HardwareShop/HardwareShopWorkerApp/Views/Home/Comments.cshtml b/HardwareShop/HardwareShopWorkerApp/Views/Home/Comments.cshtml index b2f545b..c6cfb70 100644 --- a/HardwareShop/HardwareShopWorkerApp/Views/Home/Comments.cshtml +++ b/HardwareShop/HardwareShopWorkerApp/Views/Home/Comments.cshtml @@ -17,7 +17,7 @@

Комментарии

- +
- - + Привязать -
diff --git a/HardwareShop/HardwareShopWorkerApp/Views/Home/CreatePurchase.cshtml b/HardwareShop/HardwareShopWorkerApp/Views/Home/CreatePurchase.cshtml index 80a61ba..10270c2 100644 --- a/HardwareShop/HardwareShopWorkerApp/Views/Home/CreatePurchase.cshtml +++ b/HardwareShop/HardwareShopWorkerApp/Views/Home/CreatePurchase.cshtml @@ -16,7 +16,6 @@

Товары

-
diff --git a/HardwareShop/HardwareShopWorkerApp/Views/Home/LinkPurchase.cshtml b/HardwareShop/HardwareShopWorkerApp/Views/Home/LinkPurchase.cshtml index 2c23262..4a7cc40 100644 --- a/HardwareShop/HardwareShopWorkerApp/Views/Home/LinkPurchase.cshtml +++ b/HardwareShop/HardwareShopWorkerApp/Views/Home/LinkPurchase.cshtml @@ -13,7 +13,7 @@
@{

- +

@@ -224,11 +224,11 @@
- - - - - + + + + +
diff --git a/HardwareShop/HardwareShopWorkerApp/Views/Home/UpdatePurchase.cshtml b/HardwareShop/HardwareShopWorkerApp/Views/Home/UpdatePurchase.cshtml index 0ce73e8..0b2b803 100644 --- a/HardwareShop/HardwareShopWorkerApp/Views/Home/UpdatePurchase.cshtml +++ b/HardwareShop/HardwareShopWorkerApp/Views/Home/UpdatePurchase.cshtml @@ -17,7 +17,6 @@

Товары

-
diff --git a/HardwareShop/HardwareShopWorkerApp/Views/Home/WorkerReport.cshtml b/HardwareShop/HardwareShopWorkerApp/Views/Home/WorkerReport.cshtml index 8d6a8ce..93ebc95 100644 --- a/HardwareShop/HardwareShopWorkerApp/Views/Home/WorkerReport.cshtml +++ b/HardwareShop/HardwareShopWorkerApp/Views/Home/WorkerReport.cshtml @@ -3,29 +3,15 @@ Layout = "~/Views/Shared/_LayoutWorker.cshtml"; } -

Отчет по покупкам

- -
-
-

+
+
+ + + +
-
- -
-
-

Дата начала:

- -
-
-

Дата конца:

- -
- - + +

@@ -34,21 +20,20 @@  по  ...

-
-
- - - - - - - - - - - -
Номер покупкиДата покупкиСумма покупкиКомментарииКомплектующие
-
+ + + + + + + + + + + + + +
Номер покупкиДата покупкиСумма покупкиКомментарииКомплектующие
@section Scripts { @@ -72,9 +57,6 @@ "DateFrom": dateFrom, "DateTo": dateTo }; - if (!validate(reportModel)) { - return; - } $.ajax({ url: "/home/WorkerReport", type: "POST", @@ -94,9 +76,6 @@ "DateFrom": dateFrom, "DateTo": dateTo }; - if (!validate(reportModel)) { - return; - } $.ajax({ url: "/home/SendByMailPurchaseReport", type: "POST", @@ -159,22 +138,6 @@ // [Other] - const validate = function (reportModel) { - if (isNaN(reportModel["DateFrom"])) { - errorP.innerHTML = "Выберите начальную дату"; - return false; - } - if (isNaN(reportModel["DateTo"])) { - errorP.innerHTML = "Выберите конечную дату"; - return false; - } - if (reportModel["DateFrom"] >= reportModel["DateTo"]) { - errorP.innerHTML = "Начальная дата должна быть меньше конечной"; - return false; - } - return true; - } - const getDate = function (iso) { const year = iso.substring(0, 4); const month = iso.substring(5, 7); diff --git a/HardwareShop/HardwareShopWorkerApp/Views/Home/listComponents.cshtml b/HardwareShop/HardwareShopWorkerApp/Views/Home/listComponents.cshtml index ea4942c..ed1dc8d 100644 --- a/HardwareShop/HardwareShopWorkerApp/Views/Home/listComponents.cshtml +++ b/HardwareShop/HardwareShopWorkerApp/Views/Home/listComponents.cshtml @@ -24,8 +24,8 @@
- - + +
diff --git a/HardwareShop/HardwareShopWorkerApp/Views/Shared/_LayoutWorker.cshtml b/HardwareShop/HardwareShopWorkerApp/Views/Shared/_LayoutWorker.cshtml index 2b7096b..aa26c35 100644 --- a/HardwareShop/HardwareShopWorkerApp/Views/Shared/_LayoutWorker.cshtml +++ b/HardwareShop/HardwareShopWorkerApp/Views/Shared/_LayoutWorker.cshtml @@ -36,6 +36,9 @@ +