From 7261bc69147a0472b766375f7cd77761522cc401 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=8F=D1=80=20=D0=90=D0=B3=D0=BB?=
 =?UTF-8?q?=D0=B8=D1=83=D0=BB=D0=BB=D0=BE=D0=B2?= <danuar228@mail.ru>
Date: Wed, 8 Mar 2023 17:00:31 +0400
Subject: [PATCH] =?UTF-8?q?Revert=20"=D0=92=D1=80=D0=B5=D0=BC=D0=B5=D0=BD?=
 =?UTF-8?q?=D0=BD=D1=8B=D0=B9=20=D0=BA=D0=BE=D1=81=D1=82=D1=8B=D0=BB=D1=8C?=
 =?UTF-8?q?"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit 49c182a59184a9611fd271252916fe6f78a40aaf.
---
 ConfectioneryDatabaseImplement/Shop.cs | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/ConfectioneryDatabaseImplement/Shop.cs b/ConfectioneryDatabaseImplement/Shop.cs
index bd87290..190e58d 100644
--- a/ConfectioneryDatabaseImplement/Shop.cs
+++ b/ConfectioneryDatabaseImplement/Shop.cs
@@ -106,16 +106,12 @@ namespace ConfectioneryDatabaseImplement.Models
                 }
             }
             var shop = context.Shops.First(x => x.Id == model.Id);
-			foreach (var pc in model.Pastries)
-			{
-				context.PastryComponents.Add(new()
-				{
-					Pastry = context.Pastries.First(y => y.Id == pc.Key),
-					Count = pc.Value.Item2,
-				});
-				context.SaveChanges();
-			}
-			context.SaveChanges();
+            shop.ShopPastries.AddRange(model.Pastries.Select(x => new ShopPastry
+            {
+                Pastry = context.Pastries.First(y => y.Id == x.Key),
+                Count = x.Value.Item2,
+            }).Except(shopPastries ?? new()));
+            context.SaveChanges();
             _cachedPastries = null;
         }
     }