Example #1
0
        public void AddOrder(Order order)
        {
            //take care of order basics
            _db.Add(Mapper.Map(order));
            //take care of individual pizzas
            foreach (var p in order.Pizzas)
            {
                Data.Pizzas datP = Mapper.Map(p);
                _db.Add(datP);
                Save();
                OrderPizzaJunction opj = new OrderPizzaJunction {
                    OrderId = order.Id, Quantity = 1, PizzaId = datP.Id
                };
                AddOrderPizzaJunction(opj);
                //add crust to ingredients
                Data.Ingredients datI = Mapper.Map(new Ingredient {
                    Name = p.CrustType, Type = "crust"
                });
                AddPizzaIngredientJunction(new PizzaIngredientJunction {
                    PizzaId = datP.Id, IngredientId = datI.Name
                });
                //add sauce to ingredients
                datI = Mapper.Map(new Ingredient {
                    Name = p.SauceType, Type = "sauce"
                });
                AddPizzaIngredientJunction(new PizzaIngredientJunction {
                    PizzaId = datP.Id, IngredientId = datI.Name
                });

                //add remaining toppings to ingredients
                foreach (var t in p.Toppings)
                {
                    datI = Mapper.Map(new Ingredient {
                        Name = t, Type = "topping"
                    });
                    AddPizzaIngredientJunction(new PizzaIngredientJunction {
                        PizzaId = datP.Id, IngredientId = datI.Name
                    });
                }
                Save();
            }
        }
Example #2
0
 public void AddIngredient(Data.Ingredients i)
 {
     _db.Add(i);
 }
Example #3
0
 public static Ingredient Map(Data.Ingredients otherIng) => new Ingredient
 {
     Name = otherIng.Name,
     Type = otherIng.Type,
     //Quantity = Map(otherIng.LocationIngredientJunction)
 };