コード例 #1
0
        public async Task <IActionResult> DeleteLab([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var lab = await _laboratoryService.SearchLabById(id);

            //check out if exists
            if (lab == null)
            {
                return(NotFound());
            }

            try
            {
                await _laboratoryService.DeleteLaboratory(lab);
            }
            catch (DbUpdateConcurrencyException ex)
            {
                Console.WriteLine(ex);
                return(BadRequest());
            }

            return(Ok(lab));
        }