From 6f449c505bfe7bea03d6062610e68b1e413fc73c Mon Sep 17 00:00:00 2001 From: dasha Date: Fri, 19 May 2023 17:30:44 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9A=D0=9E=D0=9B=D0=AF=20=D0=94=D0=95=D0=A0?= =?UTF-8?q?=D0=96=D0=98=20=D0=98=D0=97=D0=9C=D0=95=D0=9D=D0=95=D0=9D=D0=98?= =?UTF-8?q?=D0=AF=20=D0=9A=D0=90=D0=9A=20=D0=A2=D0=AB=20=D0=98=20=D0=9F?= =?UTF-8?q?=D0=A0=D0=9E=D0=A1=D0=98=D0=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/HomeController.cs | 4 ++-- .../HardwareShopClientApp/Views/Home/Privacy.cshtml | 2 +- .../HardwareShopClientApp/Views/Home/Register.cshtml | 8 ++++---- .../Views/Shared/_LayoutStorekeeper.cshtml | 3 +++ .../HardwareShopDatabase.cs | 2 +- .../Implements/Storekeeper/ComponentStorage.cs | 10 ++++++++-- .../Views/Home/LinkPurchase.cshtml | 4 ++-- .../HardwareShopWorkerApp/Views/Home/Register.cshtml | 8 ++++---- 8 files changed, 25 insertions(+), 16 deletions(-) diff --git a/HardwareShop/HardwareShopClientApp/Controllers/HomeController.cs b/HardwareShop/HardwareShopClientApp/Controllers/HomeController.cs index bc76ab8..b89dca1 100644 --- a/HardwareShop/HardwareShopClientApp/Controllers/HomeController.cs +++ b/HardwareShop/HardwareShopClientApp/Controllers/HomeController.cs @@ -55,7 +55,7 @@ namespace HardwareShopStorekeeperApp.Controllers } [HttpPost] - public void Privacy(string login, string email, string password) + public IActionResult Privacy(string login, string email, string password) { if (APIClient.User == null) { @@ -77,7 +77,7 @@ namespace HardwareShopStorekeeperApp.Controllers APIClient.User.Email = email; APIClient.User.Password = password; - RedirectToAction("MainStorekeeper", "Storekeeper"); + return RedirectToAction("MainStorekeeper", "Storekeeper"); } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] diff --git a/HardwareShop/HardwareShopClientApp/Views/Home/Privacy.cshtml b/HardwareShop/HardwareShopClientApp/Views/Home/Privacy.cshtml index 1984ba8..2659243 100644 --- a/HardwareShop/HardwareShopClientApp/Views/Home/Privacy.cshtml +++ b/HardwareShop/HardwareShopClientApp/Views/Home/Privacy.cshtml @@ -5,7 +5,7 @@ @{ ViewData["Title"] = "Privacy Policy"; - Layout = "~/Views/Shared/_LayoutWorker.cshtml"; + Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml"; }

Личные данные

diff --git a/HardwareShop/HardwareShopClientApp/Views/Home/Register.cshtml b/HardwareShop/HardwareShopClientApp/Views/Home/Register.cshtml index b0e0192..bb7a407 100644 --- a/HardwareShop/HardwareShopClientApp/Views/Home/Register.cshtml +++ b/HardwareShop/HardwareShopClientApp/Views/Home/Register.cshtml @@ -17,14 +17,14 @@

Регистрация

-
- - -
+
+ + +
diff --git a/HardwareShop/HardwareShopClientApp/Views/Shared/_LayoutStorekeeper.cshtml b/HardwareShop/HardwareShopClientApp/Views/Shared/_LayoutStorekeeper.cshtml index b9a3b55..df48df6 100644 --- a/HardwareShop/HardwareShopClientApp/Views/Shared/_LayoutStorekeeper.cshtml +++ b/HardwareShop/HardwareShopClientApp/Views/Shared/_LayoutStorekeeper.cshtml @@ -35,6 +35,9 @@ +
diff --git a/HardwareShop/HardwareShopDatabaseImplement/HardwareShopDatabase.cs b/HardwareShop/HardwareShopDatabaseImplement/HardwareShopDatabase.cs index 36bfb0d..af8e862 100644 --- a/HardwareShop/HardwareShopDatabaseImplement/HardwareShopDatabase.cs +++ b/HardwareShop/HardwareShopDatabaseImplement/HardwareShopDatabase.cs @@ -10,7 +10,7 @@ namespace HardwareShopDatabaseImplement { protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - optionsBuilder.UseNpgsql("Host=localhost;Port=5433;Database=Computer_Hardware_Store;Username=user;Password=12345"); + optionsBuilder.UseNpgsql("Host=localhost;Port=5433;Database=Computer_Hardware_Store1;Username=user;Password=12345"); AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); } diff --git a/HardwareShop/HardwareShopDatabaseImplement/Implements/Storekeeper/ComponentStorage.cs b/HardwareShop/HardwareShopDatabaseImplement/Implements/Storekeeper/ComponentStorage.cs index 129488b..d23d75b 100644 --- a/HardwareShop/HardwareShopDatabaseImplement/Implements/Storekeeper/ComponentStorage.cs +++ b/HardwareShop/HardwareShopDatabaseImplement/Implements/Storekeeper/ComponentStorage.cs @@ -21,9 +21,15 @@ namespace HardwareShopDatabaseImplement.Implements.Storekeeper var componentGoods = context.GoodsComponents.Where(x => x.ComponentId == element.Id).ToList(); componentGoods.ForEach(x => { - var good = context.Goods.FirstOrDefault(rec => rec.Id == x.GoodId); + var good = context.Goods.Include(x => x.Components).FirstOrDefault(rec => rec.Id == x.GoodId); if (good != null) - context.Goods.Remove(good); + if (good.GoodComponents.Count == 1) + context.Goods.Remove(good); + else + { + good.Price -= element.Cost * x.Count; + good.Price = Math.Round(good.Price, 2); + } }); context.Components.Remove(element); context.SaveChanges(); diff --git a/HardwareShop/HardwareShopWorkerApp/Views/Home/LinkPurchase.cshtml b/HardwareShop/HardwareShopWorkerApp/Views/Home/LinkPurchase.cshtml index 7c8bad6..9730923 100644 --- a/HardwareShop/HardwareShopWorkerApp/Views/Home/LinkPurchase.cshtml +++ b/HardwareShop/HardwareShopWorkerApp/Views/Home/LinkPurchase.cshtml @@ -54,10 +54,10 @@
diff --git a/HardwareShop/HardwareShopWorkerApp/Views/Home/Register.cshtml b/HardwareShop/HardwareShopWorkerApp/Views/Home/Register.cshtml index b0e0192..bb7a407 100644 --- a/HardwareShop/HardwareShopWorkerApp/Views/Home/Register.cshtml +++ b/HardwareShop/HardwareShopWorkerApp/Views/Home/Register.cshtml @@ -17,14 +17,14 @@

Регистрация

-
- - -
+
+ + +