public void DeleteDoctor(int id) { var doctor = new Doctor { IdDoctor = id }; _context.Attach(doctor); _context.Remove(doctor); _context.SaveChanges(); }
public void DeleteDoctor(int id) { var doctor = _context.Doctor.Find(id); if (doctor == null) { return; } var prescriptions = _context.Prescription.Where(e => e.IdDoctor == id); foreach (var prescription in prescriptions) { doctor.Prescription.Remove(prescription); } _context.Remove(doctor); _context.SaveChanges(); }