Exemplo n.º 1
0
        public IActionResult PutChecklist(int id, [FromBody] Checklist entity)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != entity.Id)
            {
                return(BadRequest());
            }

            Checklist checklist;

            try
            {
                checklist = _service.Update(id, entity);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!_service.ChecklistExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw new AppException("Update failed");
                }
            }
            return(Ok(checklist));
        }