From 631b3fdb72f160486057f8f6b51d4672bd5a02d3 Mon Sep 17 00:00:00 2001 From: dasha Date: Tue, 11 Apr 2023 16:12:02 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=BE=D1=84=D0=B8=D0=BA=D1=81=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SushiBar/SushiBarDatabaseImplement/Implements/ShopStorage.cs | 3 ++- SushiBar/SushiBarFileImplement/Models/Shop.cs | 3 ++- SushiBar/SushiBarListImplement/Models/Shop.cs | 3 ++- SushiBar/SushiBarRestApi/Controllers/ShopController.cs | 1 + 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/SushiBar/SushiBarDatabaseImplement/Implements/ShopStorage.cs b/SushiBar/SushiBarDatabaseImplement/Implements/ShopStorage.cs index c1331d7..e467b77 100644 --- a/SushiBar/SushiBarDatabaseImplement/Implements/ShopStorage.cs +++ b/SushiBar/SushiBarDatabaseImplement/Implements/ShopStorage.cs @@ -76,7 +76,8 @@ namespace SushiBarDatabaseImplement.Implements } shop.Update(model); context.SaveChanges(); - shop.UpdateSushi(context, model); + if (model.ListSushi != null) + shop.UpdateSushi(context, model); transaction.Commit(); return shop.GetViewModel; } diff --git a/SushiBar/SushiBarFileImplement/Models/Shop.cs b/SushiBar/SushiBarFileImplement/Models/Shop.cs index fb4a66a..9a08a30 100644 --- a/SushiBar/SushiBarFileImplement/Models/Shop.cs +++ b/SushiBar/SushiBarFileImplement/Models/Shop.cs @@ -80,7 +80,8 @@ namespace SushiBarFileImplement.Models Address = model.Address; DateOpening = model.DateOpening; MaxCountSushi = model.MaxCountSushi; - CountSushi = model.ListSushi.ToDictionary(x => x.Key, x => x.Value.Item2); + if (model.ListSushi != null) + CountSushi = model.ListSushi.ToDictionary(x => x.Key, x => x.Value.Item2); _shopSushi = null; } public ShopViewModel GetViewModel => new() diff --git a/SushiBar/SushiBarListImplement/Models/Shop.cs b/SushiBar/SushiBarListImplement/Models/Shop.cs index f209f1d..6428a3d 100644 --- a/SushiBar/SushiBarListImplement/Models/Shop.cs +++ b/SushiBar/SushiBarListImplement/Models/Shop.cs @@ -39,7 +39,8 @@ namespace SushiBarListImplement.Models ShopName = model.ShopName; Address = model.Address; DateOpening = model.DateOpening; - ListSushi = model.ListSushi; + if (model.ListSushi != null) + ListSushi = model.ListSushi; } public ShopViewModel GetViewModel => new() { diff --git a/SushiBar/SushiBarRestApi/Controllers/ShopController.cs b/SushiBar/SushiBarRestApi/Controllers/ShopController.cs index db72cf6..65fa774 100644 --- a/SushiBar/SushiBarRestApi/Controllers/ShopController.cs +++ b/SushiBar/SushiBarRestApi/Controllers/ShopController.cs @@ -72,6 +72,7 @@ namespace SushiBarRestApi.Controllers { try { + model.ListSushi = null!; _shop.Update(model); } catch (Exception ex)