Пример #1
0
        /// <summary>
        /// Adds a RecipeItem to the database, assigns it to a product.
        /// A product will be marked as set. From this moment forward it can't be changed without reloading the View(Model).
        /// </summary>
        /// <param name="item">The RecipeItem (created by the view) that has to be added.</param>
        private void AddRecipeItem(RecipeItem item)
        {
            IsProductNotSet = false;

            ProductRecipeItems.Add(SelectedRecipeItem);

            if (ActionToTake == "edit")
            {
                _recipeRepo.AddRecipe(SelectedRecipeItem);
            }

            Data.RecipeItem tempRecipeItem = SelectedRecipeItem;
            SelectedRecipeItem         = new RecipeItem();
            SelectedRecipeItem.Product = tempRecipeItem.Product;
        }
Пример #2
0
 /// <summary>
 /// Removes a RecipeItem from the database and the product.
 /// </summary>
 /// <param name="r">The RecipeItem selected in the view that has to be deleted.</param>
 private void DeleteRecipeItem(RecipeItem r)
 {
     try
     {
         if (ActionToTake == "add")
         {
             ProductRecipeItems.Remove(r);
         }
         else
         {
             ProductRecipeItems.Remove(r);
             _recipeRepo.DeleteRecipe(r);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }