public List <List <string> > GetDrinks() { var temp = Drinks.ToList(); Drinks.Clear(); return(temp); }
public void AddDrinks(List <Drink> drinks) { Drinks.Clear(); foreach (var drink in drinks) { Drinks.Add(drink); } }
private async Task Refresh() { Drinks.Clear(); var drinks = await _drinkSerice.RefreshAll(); foreach (var drink in drinks) { Drinks.Add(drink); } }
public async Task Activate() { using (Drinks.SuppressChangeNotifications()) { Drinks.Clear(); var drinkRecipes = await _drinkRecipeRepository.GetAllAsync(); var result = drinkRecipes.Select(drinkRecipe => new DrinkRecipeViewModel(drinkRecipe)).ToList(); Drinks.AddRange(result); } }
private async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { App.Current.Properties.TryGetValue("token", out object tokenObject); var user = await userService.GetUser(tokenObject.ToString()); App.Current.Properties["coctelesFav"] = user.CoctelesFavList; App.Current.Properties["ingredientesFav"] = user.IngredientesFavList; var cocteles = await CoctelService.RetrieveDrinks(); var ingredientes = await CoctelService.RetrieveIngredients(); Drinks.Clear(); foreach (var coctelFav in user.CoctelesFavList) { var d = cocteles.FirstOrDefault(x => int.Parse(x.Id) == coctelFav); if (d != null) { Drinks.Add(d); } } Ingredients.Clear(); foreach (var ingredientFav in user.IngredientesFavList) { Ingredients.Add(ingredientes.FirstOrDefault(x => x.Name.Equals(ingredientFav))); } } catch (Exception ex) { Debug.WriteLine(ex); DependencyService.Get <IMessage>().ShortAlert("No se han podido recuperar los datos de usuario. Compruebe la conexion de red"); } finally { IsBusy = false; } }
private async void searchBtn_Clicked(object sender, EventArgs e) { if (searchEntry.Text.Trim().Length > 0) { //FetchingData = false; string searchTerm = searchEntry.Text.Trim(); Drinks.Clear(); Drinks = new ObservableCollection <Drink>(await App.DrinksManager.GetDrinksAsync(2, searchTerm)); //drinks = await App.DrinksManager.GetDrinksAsync(2, searchTerm); //if (drinks.Any()) //{ // NoItems = false; //} //else //{ // NoItems = true; //} resultList.ItemsSource = Drinks; //resultList.r } }
private async Task LoadDrinks() { try { Drinks.Clear(); await Task.Delay(2000); var drinks = GetDrinks(); drinks.ForEach(d => Drinks.Add(d)); this.smwMachine.TryFireTrigger(SMWorkflowMachine.Trigger.SelectedDrink); if (Drinks.Count > 0) { SelectedDrink = Drinks.First(); } } catch (Exception) { this.smwMachine.TryFireTrigger(SMWorkflowMachine.Trigger.NotFound); } }
private async void categoryPicker_SelectedIndexChanged(object sender, EventArgs e) { if (categoryPicker.SelectedIndex > -1) { //FetchingData = false; Drinks.Clear(); //string test = categoryPicker.Items[categoryPicker.SelectedIndex]; Drinks = new ObservableCollection <Drink>(await App.DrinksManager.GetDrinksAsync(5, categoryPicker.Items[categoryPicker.SelectedIndex])); if (!Drinks.Any()) { return; } //drinks = await App.DrinksManager.GetDrinksAsync(5, e.ToString()); //if(drinks.Any()) //{ // NoItems = false; //} //else //{ // NoItems = true; //} resultList.ItemsSource = Drinks; } }