public async Task Delete_ShouldRemoveTodoItem() { var service = new TodoItemService(Context); await service.Delete(1); Assert.Empty(Context.TodoItems); }
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)); }
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; } }
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)); }
public IActionResult DeleteTodoItems(int listId, int id) { _todoItemService.Delete(listId, id); return(Ok()); }
// DELETE: api/TodoItem/5 public void Delete(int id) { _service.Delete(id); }
public Task <ActionResponse> DeleteToDoItem(ToDoItem toDoItem) { var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); return(_todoService.Delete(userId, toDoItem)); }