public async Task Delete_ShouldRemoveTodoItem()
        {
            var service = new TodoItemService(Context);

            await service.Delete(1);

            Assert.Empty(Context.TodoItems);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Delete(int?id)
        {
            if (id != null)
            {
                await todoItemService.Delete(id.Value);
            }

            return(RedirectToAction(nameof(Index)));
        }
        public IActionResult DeleteTodoItem(int id)
        {
            TodoItem todoItem = _todoItemService.FindById(id);

            if (todoItem == null)
            {
                return(NotFound());
            }

            _todoItemService.Delete(id);
            return(Ok(todoItem));
        }
        public async Task <IActionResult> DeleteTodoItem([FromRoute] Guid id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var foundItem = await _context.Find(id);

            if (foundItem == null)
            {
                return(NotFound($"Item with ID {id} was not found"));
            }

            await _context.Delete(id);

            return(Ok(id));
        }
Ejemplo n.º 5
0
        private async void OnDeleteTask(object obj)
        {
            var todo = (TodoItem)obj;

            try
            {
                IsSending = true;
                await _service.Delete(todo.Id);
                await RefreshTodos();
            }
            catch (TodoMashException ex)
            {
                _notifier.ShowError(ex.Message);
            }
            finally
            {
                IsSending = false;
            }
        }
Ejemplo n.º 6
0
        public async Task Delete_Should_CallRepository()
        {
            // Arrange
            var itemId = Guid.NewGuid();

            _repositoryMock
            .Setup(x => x.Delete(itemId))
            .Returns(Task.CompletedTask);
            _unitOfWorkMock
            .Setup(x => x.Save())
            .ReturnsAsync(true);

            // Act
            var actual = await _service.Delete(itemId);

            // Assert
            Assert.True(actual);
            _repositoryMock.Verify(x => x.Delete(itemId), Times.Once());
            _unitOfWorkMock.Verify(x => x.Save(), Times.Once());
        }
 public List <TodoItem> DeleteTodoItemById(int listId, int id)
 {
     return(service.Delete(listId, id));
 }
Ejemplo n.º 8
0
 public IActionResult DeleteTodoItems(int listId, int id)
 {
     _todoItemService.Delete(listId, id);
     return(Ok());
 }
Ejemplo n.º 9
0
 // DELETE: api/TodoItem/5
 public void Delete(int id)
 {
     _service.Delete(id);
 }
Ejemplo n.º 10
0
        public Task <ActionResponse> DeleteToDoItem(ToDoItem toDoItem)
        {
            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);

            return(_todoService.Delete(userId, toDoItem));
        }