Example #1
0
        public async Task <ActionResult <Patient> > DeletePatient(long id)
        {
            var patient = await _context.Patients.FindAsync(id);

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

            if (patient.Deleted)
            {
                return(BadRequest("Patient already deleted"));
            }

            patient.Deleted = true;

            _context.Entry(patient).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            await _relationshipService.DeleteDosagePatientId(id);

            return(patient);
        }