/**
         * Create pizza products from the pizzaIngredient table. Also imports the sauce since the pizza_ingredient import file
         * is the only source for both sauces and pizzas.
         */
        private product createPizzaProduct(DataRow lineInformation)
        {
            productcategory category = this.productImporter.findOrCreateCategory((string)lineInformation.ItemArray[0]);
            product         product  = new product();

            product.name             = (string)lineInformation.ItemArray[2];
            product.productcategory1 = this.productImporter.findOrCreateCategory((string)lineInformation.ItemArray[1], category);
            product.description      = (string)lineInformation.ItemArray[3];
            product.isspicy          = lineInformation.ItemArray[6].ToString().ToUpper() == "JA";
            product.isvegetarian     = lineInformation.ItemArray[7].ToString().ToUpper() == "JA";

            productprice price = new productprice();

            price.countrycode = this.countrycode;
            price.price       = Decimal.Parse(Regex.Replace(lineInformation.ItemArray[4].ToString(), "[^0-9.]", "")) / 100;

            sauce sauce = this.GetOrCreateSauce((string)lineInformation.ItemArray[11]);

            product.sauce = sauce;

            database.products.Add(product);
            Console.WriteLine(
                "New pizza {0} created with sauce {1}",
                (string)lineInformation.ItemArray[2],
                (string)lineInformation.ItemArray[11]
                );

            database.SaveChanges();

            return(product);
        }
        private sauce GetOrCreateSauce(string saucename)
        {
            sauce sauce = this.database.sauces.SingleOrDefault(s => s.name == saucename);

            if (sauce == null)
            {
                sauce      = new sauce();
                sauce.name = saucename;
            }
            return(sauce);
        }
示例#3
0
 public PizzaOven()
 {
     Ingredients    = new Dictionary <System.Type, Consumable>();
     MaxIngredients = new Dictionary <System.Type, double>();
     Ingredients[typeof(cheese)]      = new cheese();
     Ingredients[typeof(dough)]       = new dough();
     Ingredients[typeof(sauce)]       = new sauce();
     Ingredients[typeof(toppings)]    = new toppings();
     Ingredients[typeof(money)]       = new money();
     Ingredients[typeof(pizza)]       = new pizza();
     MaxIngredients[typeof(cheese)]   = 5;
     MaxIngredients[typeof(dough)]    = 10;
     MaxIngredients[typeof(sauce)]    = 5;
     MaxIngredients[typeof(toppings)] = 10;
     MaxIngredients[typeof(money)]    = 100000000000000000;
 }