Ejemplo n.º 1
0
 private void btn_AddRecipe_Click(object sender, EventArgs e)
 {
     Recipe.Recipe newRecipe = new Recipe.Recipe();
     newRecipe.Name = "new Recipe";
     if (txt_newIngredient.Text != "")
     {
         newRecipe.Name         = txt_newIngredient.Text;
         txt_newIngredient.Text = "";
     }
     rsStorage.AddRecipe(newRecipe);
     init();
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            RecipeDataProviderImpl rsStorage = new RecipeDataProviderImpl("test.csv");

            if (rsStorage.Ingredients.Count == 0)
            {
                foreach (String ingName in TEST_ING_NAMES)
                {
                    Ingredient tmpIng = new Ingredient();
                    tmpIng.Name = ingName;
                    System.Console.WriteLine("Add Ingredient: " + tmpIng);
                    rsStorage.AddIngredient(tmpIng);
                }
            }
            if (rsStorage.Recipes.Count == 0)
            {
                Recipe.Recipe kuchenRcp = new Recipe.Recipe();
                kuchenRcp.Name = "Kuchen";
                kuchenRcp.Text = "Zubereitung";
                RecipeItem mehlItem = new RecipeItem();
                mehlItem.Count      = 1;
                mehlItem.Unit       = "Tasse";
                mehlItem.Ingredient = rsStorage.Ingredients[2];
                RecipeItem backPulverItem = new RecipeItem();
                backPulverItem.Count           = 2;
                backPulverItem.Unit            = "Messerspitze";
                backPulverItem.Ingredient      = new Ingredient();
                backPulverItem.Ingredient.Name = "Backpulver";
                kuchenRcp.addIngredient(mehlItem);
                kuchenRcp.addIngredient(backPulverItem);
                rsStorage.AddRecipe(kuchenRcp);
                System.Console.WriteLine("Add Recipe: " + kuchenRcp);
            }
            foreach (Ingredient ing in rsStorage.Ingredients)
            {
                System.Console.WriteLine("Got stored ingredient {0}", ing);
            }
            foreach (Recipe.Recipe rcp in rsStorage.Recipes)
            {
                System.Console.WriteLine("Got stored recipe {0}", rcp);
            }
            System.Console.ReadKey();
        }