public ActionResult <TodoItemModel> Post([FromBody] TodoItemModel item) { if (item == null) { throw new ArgumentException(nameof(item)); } return(_repo.Add(item)); }
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); }
public void Add(TodoItems entity) { _todoItemsRepository.Add(entity); }