private void Recipes_ObjectIsSelectedChanged(object sender, EventArgs e) { ImportCookingDataViewModel vm = DataContext as ImportCookingDataViewModel; list_categories.ItemsSource = vm.Categories.ExportObjects; list_categories.Items.Refresh(); list_ingredients.ItemsSource = vm.Ingredients.ExportObjects; list_ingredients.Items.Refresh(); vm.RefreshSelectedCount(); }
private void Import_Click(object sender, RoutedEventArgs e) { ImportCookingDataViewModel vm = DataContext as ImportCookingDataViewModel; // Iterate through recipe ingredients and check if not existing in user library foreach (ExportObject <Ingredient> importedIngredient in vm.Ingredients.ExportObjects.Where(x => x.IsSelected)) { if (importedIngredient.Data is Ingredient ingredient) { if (!App.AvailableIngredients .Any(x => x.Name.Equals(ingredient.Name, StringComparison.InvariantCultureIgnoreCase))) { App.AvailableIngredients.Add(ingredient); } } } // Iterate through recipe categories and check if not existing in user library foreach (ExportObject <Category> importedCategory in vm.Categories.ExportObjects.Where(x => x.IsSelected)) { if (importedCategory.Data is Category category) { if (!App.AvailableCategories .Any(x => x.Name.Equals(category.Name, StringComparison.InvariantCultureIgnoreCase))) { App.AvailableCategories.Add(category); } } } App.SaveCookingData(); App.LoadCookingData(); Mediator.Instance.NotifyColleagues(ViewModelMessage.CookingDataImported, null); }