示例#1
0
 public IActionResult DeleteToDo([FromBody] ToDoListItem toDoListItem)
 {
     try
     {
         _toDoListItemRepository.Delete(toDoListItem);
         return(Ok());
     } catch (Exception ex)
     {
         return(BadRequest(ex));
     }
 }
        public void DeleteListItem()
        {
            ToDoLists.Lists.Add(1, new List <ToDoList>());
            ToDoList toDoList = new ToDoList
            {
                UserID = 1,
                Title  = "Test list"
            };

            var insertedList = _toDoListRepository.Create(toDoList);
            var listItem     = new ToDoListItem
            {
                UserID     = 1,
                Title      = "Test item 1",
                ToDoListID = insertedList.ID,
                Content    = "Lorem ipsum dolor sit amet, consectetur adipiscing elit"
            };

            var insertedItem = _toDoListItemRepository.Create(listItem);

            _toDoListItemRepository.Delete(insertedItem);

            Assert.AreEqual(0, ToDoLists.Lists[1].FirstOrDefault(l => l.ID == insertedList.ID).ToDoListItems.Count());
        }