public AddIngredientsViewModel(AddIngredientsView addIngredientsOpen, vwRecipe recipeCreated)
 {
     addIngredients      = addIngredientsOpen;
     recipe              = recipeCreated;
     Ingredient          = new vwIngredient();
     ingredient.RecipeId = recipeCreated.RecipeId;
 }
Beispiel #2
0
 public AddIngredientsViewModel(AddIngredientsView aiv, tblRecipe rec)
 {
     view            = aiv;
     Recipe          = rec;
     IngredientsList = ingredientService.GetAllIngredients();
     newIngredient   = new tblIngredient();
     Ingredient      = new tblIngredient();
 }
 private void AddIngredientsExecute()
 {
     try
     {
         AddIngredientsView ingredientsView = new AddIngredientsView(Recipe);
         ingredientsView.ShowDialog();
         if ((ingredientsView.DataContext as AddIngredientsViewModel).IngredientsAdded == true)
         {
             hasIngredients = true;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Exception" + ex.Message.ToString());
     }
 }
 private void AddIngredientsExecute()
 {
     if (String.IsNullOrEmpty(Recipe.RecipeName) || String.IsNullOrEmpty(Recipe.Type) || String.IsNullOrEmpty(Recipe.NumberOfPersons.ToString()) ||
         Recipe.NumberOfPersons == 0 || String.IsNullOrEmpty(Recipe.Description))
     {
         MessageBox.Show("Please fill all fields.", "Notification");
     }
     else
     {
         try
         {
             recipes.CreateRecipe(Recipe, out int id);
             Recipe.RecipeId = id;
             AddIngredientsView addIngredients = new AddIngredientsView(Recipe);
             addRecipe.Close();
             addIngredients.ShowDialog();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString());
         }
     }
 }