public async Task UpdateAsync(ItemTodo item)
        {
            var entity = await _dbContext.ItemTodos.FindAsync(item.Id);

            entity.Name = item.Name;
            await _dbContext.SaveChangesAsync();
        }
        public void ShouldHaveNotPassWhenAddAsyncNullItemReturnThrowException()
        {
            //arrange
            var thirdItem = new ItemTodo();

            //actual

            //assert
            Assert.ThrowsAsync <DbUpdateException>(async() => await _itemToDoService.AddAsync(thirdItem));
        }
        public ItemTodo Save(ItemTodo item)
        {
            var _item = this.Get(item.Title);

            if (_item != null)
            {
                _item.Completed = item.Completed;
            }
            else
            {
                this._Items.Add(item);
            }

            return(item);
        }
Beispiel #4
0
 public IActionResult Edit([FromBody] ItemTodo item)
 {
     try
     {
         if (item == null || !ModelState.IsValid)
         {
             return(BadRequest("Invalid State"));
         }
         ItemRepository.Update(item);
     }
     catch (Exception)
     {
         return(BadRequest("Error while creating"));
     }
     return(NoContent());
 }
        public async Task ShouldHavePassWhenAddAsyncItem()
        {
            //arrange
            var thirdItem = new ItemTodo()
            {
                Id = Guid.Parse("74a1eedc-0719-408c-8c07-1bee8c2dd0b1"), Name = "Third Item"
            };
            await _itemToDoService.AddAsync(thirdItem);

            //actual
            var actualItems = await _itemToDoService.BrowsAsync();

            //assert
            Assert.That(actualItems.Any(x => x.Id == thirdItem.Id));
            Assert.AreEqual(3, actualItems.Count());
        }
        public async Task AddAsync(ItemTodo item)
        {
            await _dbContext.ItemTodos.AddAsync(item);

            await _dbContext.SaveChangesAsync();
        }
 public async Task UpdateAsync(ItemTodo item)
 => await _itemToDoRepository.UpdateAsync(item);
 public async Task AddAsync(ItemTodo item)
 => await _itemToDoRepository.AddAsync(item);
Beispiel #9
0
        public ItemTodo GetItem(string id)
        {
            ItemTodo item = ItemRepository.Get(id);

            return(item);
        }