From f6c25cf968e44d8c34ae1b77663ea59b805f7577 Mon Sep 17 00:00:00 2001 From: gg12 darfren Date: Sat, 27 Apr 2024 17:27:47 +0400 Subject: [PATCH] =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=88=D1=83=20=D0=B1=D0=B0?= =?UTF-8?q?=D0=B3=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VetClinic/VetClinicDataBaseImplement/Models/Medicine.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/VetClinic/VetClinicDataBaseImplement/Models/Medicine.cs b/VetClinic/VetClinicDataBaseImplement/Models/Medicine.cs index 88b9b6f..8700680 100644 --- a/VetClinic/VetClinicDataBaseImplement/Models/Medicine.cs +++ b/VetClinic/VetClinicDataBaseImplement/Models/Medicine.cs @@ -80,8 +80,11 @@ namespace VetClinicDataBaseImplement.Models if (medicineAnimals != null && medicineAnimals.Count > 0) { context.MedicineAnimals.RemoveRange(medicineAnimals.Where(rec -=> !model.MedicineAnimals.ContainsKey(rec.MedicineId))); - +=> !model.MedicineAnimals.ContainsKey(rec.AnimalId))); + foreach (var animal in medicineAnimals) + { + model.MedicineAnimals.Remove(animal.AnimalId); + } context.SaveChanges(); } var medicine = context.Medicines.First(x => x.Id == Id);