Beispiel #1
0
        public async Task <ActionResult <Drug> > DeleteDrug(long id)
        {
            var drug = await _context.Drugs.FindAsync(id);

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

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

            drug.Deleted = true;

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

            await _relationshipService.DeleteDosageDrugId(id);

            return(drug);
        }