示例#1
0
        public async Task <IActionResult> PutTodo([FromRoute] int id, [FromBody] Todo todo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != todo.TodoId)
            {
                return(BadRequest());
            }

            _todos.PutTodo(todo);

            try
            {
                await _todos.Commit();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!_todos.TodoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }