From 753840b2a64f58737e8f3627bca89806c5d280fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D1=8F=D1=87=D0=B5=D1=81=D0=BB=D0=B0=D0=B2=20=D0=98?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Sun, 10 Mar 2024 21:45:58 +0400 Subject: [PATCH] fix --- Hotel/HotelDataBaseImplement/Models/Room.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Hotel/HotelDataBaseImplement/Models/Room.cs b/Hotel/HotelDataBaseImplement/Models/Room.cs index 4aa5582..21877f1 100644 --- a/Hotel/HotelDataBaseImplement/Models/Room.cs +++ b/Hotel/HotelDataBaseImplement/Models/Room.cs @@ -87,7 +87,7 @@ namespace HotelDataBaseImplement.Models { var roomLunches = context.RoomLunches.Where(rec => rec.RoomId == model.Id).ToList(); - if (roomLunches != null) + if (roomLunches != null && roomLunches.Count > 0) { context.RoomLunches.RemoveRange(roomLunches.Where(rec => !model.RoomLunches.ContainsKey(rec.LunchId))); context.SaveChanges(); @@ -101,12 +101,12 @@ namespace HotelDataBaseImplement.Models var room = context.Rooms.First(x => x.Id == Id); - foreach (var cm in model.RoomLunches) + foreach (var lunch in model.RoomLunches) { context.RoomLunches.Add(new RoomLunch { Room = room, - Lunch = context.Lunches.First(x => x.Id == cm.Key) + Lunch = context.Lunches.First(x => x.Id == lunch.Key) }); context.SaveChanges(); }