public IActionResult AddItem(long todoId, [FromBody] ToDoItem item) { if (item == null || !item.CheckValidName()) { return(BadRequest()); } var todo = _todoRepository.Find(todoId); if (todo == null) { return(NotFound()); } item.TodoId = todoId; _todoRepository.AddItem(todoId, item); return(CreatedAtRoute("GetTodoItem", new { id = item.Id }, item)); }
public IActionResult UpdateItem(long id, [FromBody] ToDoItem payload) { if (payload == null || !payload.CheckValidName()) { return(BadRequest()); } var item = _todoRepository.FindItem(id); if (item == null) { return(NotFound()); } item.IsComplete = payload.IsComplete; item.Name = payload.Name; _todoRepository.UpdateItem(item); return(CreatedAtRoute("GetTodoItem", new { id = item.Id }, item)); }
public void ReturnFalseGivenNameNull() { var result = _ToDoItem.CheckValidName(); Assert.False(result, "Name should not be null"); }