private async Task ShowItemsAsync() { List <ItemModel> items = new List <ItemModel>(); Category.Items = new ObservableCollection <ItemModel>(); if (SearchItem.ItemName != "") { items = await FirebaseService.GetItemsAsync(SearchItem, 20, null); } else if (VisibleState == States[0]) { items = await FirebaseService.GetItemsAsync(Category, 20, null); } else { items = await FirebaseService.GetItemsAsync(VisibleState, 20, null); } foreach (var item in items) { var state = States.FirstOrDefault(x => x.StateID == item.StateID); item.State = state; } Category.Items = new ObservableCollection <ItemModel>(items); }
async Task ExecuteLoadStoriesCommand() { if (IsBusy) { return; } IsBusy = true; try { Stories.Clear(); var stories = await FirebaseService.GetItemsAsync(true); foreach (var story in stories) { Stories.Add(story); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
private async Task LoadMoreAsync() { if (!await CanLoadMoreAsync()) { return; } IsItemsLoading = true; if (SearchItem.ItemName != "") { var items = await FirebaseService.GetItemsAsync(SearchItem, 20, Category.Items.Last().ID); for (int i = 0; i < items.Count; i++) { items[i].State = SelectableStates.FirstOrDefault(x => x.StateID == items[i].StateID); Category.Items.Add(items[i]); } } else if (VisibleState == States[0] && Category.Items.Count != 0) { var items = await FirebaseService.GetItemsAsync(Category, 20, Category.Items.Last().ID); for (int i = 0; i < items.Count; i++) { items[i].State = SelectableStates.FirstOrDefault(x => x.StateID == items[i].StateID); Category.Items.Add(items[i]); } } else if (VisibleState.StateID != null) { var items = await FirebaseService.GetItemsAsync(VisibleState, 20, Category.Items.Last().ID); for (int i = 0; i < items.Count; i++) { items[i].State = SelectableStates.FirstOrDefault(x => x.StateID == items[i].StateID); Category.Items.Add(items[i]); } } IsItemsLoading = false; }