Пример #1
0
        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());
        }
Пример #2
0
        public async Task <ActionResult <Patient> > DeletePatient(int id)
        {
            var patient = await _repository.GetById(id);

            if (patient == null)
            {
                return(NotFound());
            }

            _repository.Delete(patient);

            return(patient);
        }