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));
        }
示例#2
0
        public HttpResponseMessage Delete(int labNumber)
        {
            var laboratory = _laboratoryService.GetByLabNumber(labNumber);

            if (laboratory == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }
            else
            {
                _laboratoryService.DeleteLaboratory(laboratory);
                return(Request.CreateResponse(HttpStatusCode.OK));
            }
        }
示例#3
0
 public void Delete(int id)
 {
     labService.DeleteLaboratory(id);
 }
示例#4
0
 public void Delete(int id)
 {
     laboratoryService.DeleteLaboratory(laboratoryService.GetById(id));
 }