public async Task <ActionResult <Todo> > Post(TodoViewModel todo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var createdTodo = await _repository.AddTodoAsync(todo.Text, todo.IsComplete); return(CreatedAtAction(nameof(Get), new { id = createdTodo.Id }, createdTodo)); }
public async Task <IActionResult> AddTodo(Todo todo) { await todoRepository.AddTodoAsync(todo); return(RedirectToAction("List")); }