public RecipesViewModel() { // initialize commands m_addNewRecipeCommand = new RelayCommand(AddNewRecipe); m_deleteRecipeCommand = new RelayCommand <RecipeDataModel>(DeleteRecipe); m_addHopsIngredientToRecipeCommand = new RelayCommand <Hops>(AddHopsIngredient); m_addFermentableIngredientToRecipeCommand = new RelayCommand <Fermentable>(AddFermentableIngredient); m_changeYeastCommand = new RelayCommand <Yeast>(ChangeYeast); m_deleteHopsIngredientCommand = new RelayCommand <IHopsIngredient>(DeleteHopsIngredient); m_deleteFermentableIngredientCommand = new RelayCommand <IFermentableIngredient>(DeleteFermentableIngredient); // get available ingredients List <IngredientTypeBase> allAvailableIngredients = RecipeUtility.GetAvailableIngredients().OrderBy(ingredient => ingredient.Name).ToList(); m_availableHops = allAvailableIngredients.OfType <Hops>().ToReadOnlyObservableCollection(); m_availableFermentables = allAvailableIngredients.OfType <Fermentable>().ToReadOnlyObservableCollection(); m_availableYeasts = allAvailableIngredients.OfType <Yeast>().ToReadOnlyObservableCollection(); List <Style> beerStyles = RecipeUtility.GetAvailableBeerStyles().OrderBy(style => style.Name).ToList(); m_availableBeerStyles = beerStyles.ToReadOnlyObservableCollection(); m_savedRecipes = new ObservableCollection <RecipeDataModel>(RecipeUtility.GetSavedRecipes(beerStyles)); GetSettings(); // set the current recipe to the first in the collection CurrentRecipe = m_savedRecipes.FirstOrDefault(); }
public BatchesViewModel() { m_addNewBatchCommand = new RelayCommand <RecipeDataModel>(AddNewBatch, CanAddNewBatch); m_deleteBatchCommand = new RelayCommand <BatchDataModel>(DeleteBatch); m_addGravityReadingCommand = new RelayCommand(AddGravityReading, CanAddGravityReading); m_deleteGravityReadingCommand = new RelayCommand <GravityReadingDataModel>(DeleteGravityReading); List <Style> beerStyles = RecipeUtility.GetAvailableBeerStyles().OrderBy(style => style.Name).ToList(); m_availableRecipes = new ObservableCollection <RecipeDataModel>(RecipeUtility.GetSavedRecipes(beerStyles)); m_savedBatches = new ObservableCollection <BatchDataModel>(BatchUtility.GetSavedBatches(m_availableRecipes)); CurrentBatch = m_savedBatches.FirstOrDefault(); }