public PizzaClass(PizzaSize size, HashSet <string> ingrediants)
 {
     Size = size;
     foreach (string item in ingrediants)
     {
         Ingrediants.Add(item);
     }
     UpdatePrice();
 }
示例#2
0
        protected void FactoryTypeList_SelectedIndexChanged(object sender, EventArgs e)
        {
            string receivedItem = FactoryTypeList.SelectedValue;

            Ingrediants makeProduct = null;

            makeProduct = Factory.GetProduct(receivedItem);

            string result = makeProduct.Connection("First", "Second");

            CurrentProductItem.Text = result;
        }
示例#3
0
        public static Ingrediants GetProduct(string choice)
        {
            Ingrediants createdProduct = null;

            if (choice.Equals("1"))
            {
                createdProduct = new ProductA();
            }
            else if (choice.Equals("2"))
            {
                createdProduct = new ProductB();
            }
            return(createdProduct);
        }
示例#4
0
        private async Task SetManyToManyRelationshipsAsync()
        {
            #region Recipes <-> Sources

            var recipe1 = this.Context.Recipes.First();

            var cookbookSource = this.Sources.First(x => x is RecipeCookbookSource);

            var cookbookRecipe1Connection = new RecipeSourceRecipe()
            {
                Page     = 4,
                Recipe   = recipe1,
                RecipeId = recipe1.Id,
                Source   = cookbookSource,
                SourceId = cookbookSource.Id
            };
            cookbookSource.RecipeSourceRecipes.Add(cookbookRecipe1Connection);
            recipe1.Source   = cookbookRecipe1Connection;
            recipe1.SourceId = cookbookSource.Id;

            var recipe2   = this.Context.Recipes.Last();
            var webSource = this.Sources.First(x => x is RecipeUrlSource);

            var webSourceRecipe2Connection = new RecipeSourceRecipe()
            {
                Recipe   = recipe2,
                RecipeId = recipe2.Id,
                Source   = webSource,
                SourceId = webSource.Id,
                Page     = 0
            };
            webSource.RecipeSourceRecipes.Add(webSourceRecipe2Connection);
            recipe2.Source   = webSourceRecipe2Connection;
            recipe2.SourceId = webSourceRecipe2Connection.SourceId;

            await this.Context.SaveChangesAsync();

            #endregion

            #region Recipes <-> Ingrediants

            var ingrediant1 = Ingrediants.ElementAt(0);
            var ingrediant2 = Ingrediants.ElementAt(1);
            var ingrediant3 = Ingrediants.ElementAt(2);
            var ingrediant4 = Ingrediants.ElementAt(3);
            var ingrediant5 = Ingrediants.ElementAt(4);

            recipe1.Ingrediants.Add(new RecipeIngrediant()
            {
                RecipeId = recipe1.Id, IngrediantId = ingrediant1.Id, Amount = 1, CookingUnit = CookingUnit.Gramm
            });
            recipe1.Ingrediants.Add(new RecipeIngrediant()
            {
                RecipeId = recipe1.Id, IngrediantId = ingrediant2.Id, Amount = 2, CookingUnit = CookingUnit.Kilogramm
            });

            recipe2.Ingrediants.Add(new RecipeIngrediant()
            {
                RecipeId = recipe2.Id, IngrediantId = ingrediant1.Id, Amount = 1, CookingUnit = CookingUnit.Bunch
            });
            recipe2.Ingrediants.Add(new RecipeIngrediant()
            {
                RecipeId = recipe2.Id, IngrediantId = ingrediant4.Id, Amount = 4, CookingUnit = CookingUnit.Liter
            });
            recipe2.Ingrediants.Add(new RecipeIngrediant()
            {
                RecipeId = recipe2.Id, IngrediantId = ingrediant5.Id, Amount = 5, CookingUnit = CookingUnit.Msp
            });
            await this.Context.SaveChangesAsync();

            #endregion

            #region Recipes <-> Tags

            var tag1 = this.Tags.ElementAt(0);
            var tag2 = this.Tags.ElementAt(1);
            var tag3 = this.Tags.ElementAt(2);

            recipe1.Tags.Add(new RecipeRecipeTag()
            {
                RecipeId = recipe1.Id, RecipeTagId = tag1.Id
            });
            recipe1.Tags.Add(new RecipeRecipeTag()
            {
                RecipeId = recipe1.Id, RecipeTagId = tag2.Id
            });
            recipe2.Tags.Add(new RecipeRecipeTag()
            {
                RecipeId = recipe2.Id, RecipeTagId = tag1.Id
            });
            recipe2.Tags.Add(new RecipeRecipeTag()
            {
                RecipeId = recipe2.Id, RecipeTagId = tag3.Id
            });
            await this.Context.SaveChangesAsync();


            #endregion
        }