public override async Task OnNavigatedTo(NavigationEventArgs e) { var recipes = await _recipesService.Load("Data\\Recipes.json"); var ds = new List <string>(); RecipeDataGroup group = null; Recipes = new ObservableCollection <RecipeDataItem>(); foreach (RecipeDataItem recipe in recipes) { Recipes.Add(recipe); if (!ds.Contains(recipe.Group.UniqueId)) { group = recipe.Group; group.Items = new ObservableCollection <RecipeDataItem>(); ds.Add(recipe.Group.UniqueId); _recipeRepository.ItemGroups.Add(group); } _recipeRepository.AssignedUserImages(recipe); if (group != null) { group.Items.Add(recipe); } } }
// Carga la colección de recetas public void LoadRecipes() { IEnumerable <RecipeDataItem> recipes = new ObservableCollection <RecipeDataItem>((this.LocalDataService.Load <RecipeDataItem>("Data\\Recipes.txt").ToList())); List <string> IDs = new List <string>(); RecipeDataGroup group = null; foreach (var recipe in recipes) { if (!IDs.Contains(recipe.Group.UniqueId)) { group = recipe.Group; group.Items = new ObservableCollection <RecipeDataItem>(); IDs.Add(recipe.Group.UniqueId); _recipeRepository.ItemGroups.Add(group); } _recipeRepository.AssignedUserImages(recipe); group.Items.Add(recipe); } }