Пример #1
0
        public ActionResult <TodoItemModel> Post([FromBody] TodoItemModel item)
        {
            if (item == null)
            {
                throw new ArgumentException(nameof(item));
            }

            return(_repo.Add(item));
        }
Пример #2
0
        public void GetAll_WhenOneItemAdded_ShouldHaveThisItemSaved()
        {
            var items = _itemsRepository.GetAll();

            Assert.AreEqual(items.Count(), 2);

            var newItem = new TodoItemModel()
            {
                Id        = 0,
                Name      = "TestName",
                IsChecked = false
            };

            newItem = _itemsRepository.Add(newItem);
            Assert.IsTrue(newItem.Id > 0);

            items = _itemsRepository.GetAll();
            Assert.AreEqual(items.Count(), 3);

            var itemFromRepo = items.FirstOrDefault(x => x.Id == newItem.Id);

            Assert.NotNull(itemFromRepo);
        }
Пример #3
0
 public void Add(TodoItems entity)
 {
     _todoItemsRepository.Add(entity);
 }