예제 #1
0
        public async Task <IActionResult> UpdateLab([FromBody] UpdateViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (model.IdLaboratory <= 0)
            {
                return(BadRequest());
            }

            try
            {
                await _laboratoryService.UpdateLaboratory(model);
            }
            catch (DbUpdateException)
            {
                if (!(await _laboratoryService.LabExists(model.IdLaboratory)))
                {
                    return(NotFound());
                }
                else
                {
                    return(BadRequest());
                }
            }

            return(Ok());
        }