public async Task <ActionResult <Patient> > DeletePatient(int id) { //var patient = await _repository.GetById(id); //if (patient == null) //{ // return NotFound(); //} //_repository.Delete(patient); //return patient; if (!await _repository.Exists(id)) { return(NotFound()); } Patient patientEntity2Delete = await _repository.GetById(id); if (patientEntity2Delete == null) { return(NotFound()); } _repository.Delete(patientEntity2Delete); if (!await _repository.Save()) { return(StatusCode(500, "A problem happened while handling your request.")); } return(NoContent()); }
public async Task <ActionResult <Patient> > DeletePatient(int id) { var patient = await _repository.GetById(id); if (patient == null) { return(NotFound()); } _repository.Delete(patient); return(patient); }