/// <summary> /// Initializes a new instance of the <see cref="HomeViewModel" /> class. /// </summary> /// <param name="mainFrameNavigationService">The main frame navigation service.</param> /// <param name="pageBaseViewModel">The page base view model.</param> /// <param name="ingredientsAccess">The recipe components access.</param> /// <param name="loadingIndicatiorModule">The loading indicatior module.</param> /// <param name="recipesAccess">The recipes access.</param> public AddEditRecipeViewModel(IMainFrameNavigationService mainFrameNavigationService, IPageBaseViewModel pageBaseViewModel, IIngredientsAccess ingredientsAccess, ILoadingIndicatiorModule loadingIndicatiorModule, IRecipesAccess recipesAccess) { _mainFrameNavigation = mainFrameNavigationService; _ingredientsAccess = ingredientsAccess; _loadingIndicatiorModule = loadingIndicatiorModule; _recipesAccess = recipesAccess; PageBaseModel = pageBaseViewModel; MealTypesCollection = new ObservableCollection <MealTypes>(); foreach (MealTypes value in Enum.GetValues(typeof(MealTypes))) { MealTypesCollection.Add(value); } UnitTypesCollection = new ObservableCollection <UnitTypes>(); foreach (UnitTypes value in Enum.GetValues(typeof(UnitTypes))) { UnitTypesCollection.Add(value); } SelectedRecipe = new Recipe(); DispatcherHelper.RunAsync(async() => { _loadingIndicatiorModule.ShowLoadingIndicatior(); var components = await _ingredientsAccess.GetIngredientsList(x => true, x => x.Name); AllIngredients = new ObservableCollection <IIngredient>(components); FilteredIngredients = new ObservableCollection <IIngredient>(AllIngredients.Where(x => true)); _loadingIndicatiorModule.HideLoadingIndicator(); }); }
/// <summary> /// Initializes a new instance of the <see cref="HomeViewModel"/> class. /// </summary> /// <param name="mainFrameNavigationService">The main frame navigation service.</param> /// <param name="pageBaseViewModel">The page base view model.</param> /// <param name="recipesAccess">The recipes access.</param> public RecipesViewModel(IMainFrameNavigationService mainFrameNavigationService, IPageBaseViewModel pageBaseViewModel, IRecipesAccess recipesAccess) { _mainFrameNavigation = mainFrameNavigationService; _recipesAccess = recipesAccess; PageBaseModel = pageBaseViewModel; DispatcherHelper.RunAsync(async() => { var recipes = await _recipesAccess.GetRecipesList(null, x => x.Name); RecipesCollection = new ObservableCollection <IRecipe>(recipes); FilteredRecipesCollection = new ObservableCollection <IRecipe>(RecipesCollection.Where(x => true)); }); //FilteredRecipesCollection.CollectionChanged += (sender, args) => //{ // RaisePropertyChanged(() => NoData); //}; }