public IActionResult DeleteDoctor(int id) { Doctor doctor = context.Doctors.Find(id); if (doctor != null) { context.Remove <Doctor>(doctor); context.SaveChanges(); return(Ok($"Doctor removed")); } return(NotFound("No such doctor")); }
public IActionResult deleteDoctor(int id) { Doctor doctor = context.Doctors.Find(id); if (doctor != null) { context.Remove <Doctor>(doctor); context.SaveChanges(); return(Ok($"doktorek o {id} usuniety")); } return(NotFound("nie ma takiego doktorka")); }
public string DeleteDoctor(int id) { var doctor = _hospitalContext.Doctors.FirstOrDefault(d => d.IdDoctor == id); if (doctor != null) { _hospitalContext.Remove(doctor); _hospitalContext.SaveChanges(); return("Doctor deleted"); } else { return("Doctor not found"); } }
public IActionResult Delete(int id) { var hospital = dbContext.Hospitals.FirstOrDefault(h => h.Id == id); if (hospital != null) { dbContext.Remove(hospital); dbContext.SaveChanges(); return(Ok()); } else { return(NotFound()); } }
public bool DeletePatient(int id) { try { using (var context = new HospitalContext()) { PatientContext patientContext = context.PatientContexts.Find(id); context.Remove(patientContext); context.SaveChanges(); } return true; } catch (Exception) { throw; } }
public bool DeleteDoctor(int id) { try { using (var context = new HospitalContext()) { DoctorContext doctorContext = context.DoctorContexts.Find(id); context.Remove(doctorContext); context.SaveChanges(); } return(true); } catch (Exception) { throw; } }