Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        public void ReturnFalseGivenNameNull()
        {
            var result = _ToDoItem.CheckValidName();

            Assert.False(result, "Name should not be null");
        }