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);