public void GetItems_ShouldReturnNullIfUserIsNotFound() { // Arrange var dbContext = SetupDatabase(nameof(GetItems_ShouldReturnNullIfUserIsNotFound)); var repository = new TodoItemRepository(dbContext); // Act var result = repository.GetItems(3, new PagingParameters()); // Assert Assert.Null(result); }
private async Task LoadData() { var items = await repository.GetItems(); if (!ShowAll) { items = items.Where(x => x.Completed == false).ToList(); } var itemViewModels = items.Select(i => CreateTodoItemViewModel(i)); Items = new ObservableCollection <TodoItemViewModel>(itemViewModels); }
private async Task LoadData() { // estraggo dal repository la lista di tipo TodoItem List <TodoItem> items = await repository.GetItems(); if (!ShowAll) { items = items.Where(x => x.Completed == false).ToList(); } // per ogni entita della lista converto l'oggetto in una lista di tipoo TodoItemViewModel List <TodoItemViewModel> itemsViewModels = items.Select(i => CreateTodoItemViewModel(i)).ToList(); // assegno la lista ViewMododelItem all'oggeto ObservableCollection. Items = new ObservableCollection <TodoItemViewModel>(itemsViewModels); }
private async Task LoadData() { var items = await repository.GetItems(); // page 89, Creating the filter toggle function using a command if (!ShowAll) { items = items.Where(x => x.Completed == false).ToList(); } var itemViewModels = items.Select( i => CreateTodoItemViewModel(i)); Items = new ObservableCollection <TodoItemViewModel>(itemViewModels); }
private async Task LoadData() { //get items var items = await repository.GetItems(); //filter items if (!ShowAll) { items = items.Where(i => i.Completed == false).ToList(); } //order items before creating ViewModels items = items.OrderBy(i => i.Due).ToList(); //create viewModels var itemViewModels = items.Select(i => CreateTodoItemViewModel(i)); Items = new ObservableCollection <TodoItemViewModel>(itemViewModels); }
public void GetItems_ShouldReturnItems() { // Arrange var dbContext = SetupDatabase(nameof(GetItems_ShouldReturnItems)); var repository = new TodoItemRepository(dbContext); var input = new PagingParameters { Search = "code" }; // Act var result = repository.GetItems(1, input); // Assert Assert.NotNull(result); Assert.Single(result.PageContent); Assert.Equal("Code review", result.PageContent[0].Description); }
private async Task LoadDataAsync() { List <TodoItem> todoItems; if (!ShowAll) { // Load only active items todoItems = await _todoRepository.GetActiveItems(); } else { // Load all items todoItems = await _todoRepository.GetItems(); } var todoItemViewModels = todoItems.Select(i => CreateTodoItemViewModel(i)); TodoItems = new ObservableCollection <TodoItemViewModel>(todoItemViewModels); }