public bool Post(PizzaViewModel pvm, long oid)
        {
            Crust crust = _cr.Get(pvm.Crust);
            Size  size  = _sr.Get(pvm.Size);

            var p = new Pizza()
            {
                CrustId = crust.Id, SizeId = size.Id, OrderId = oid
            };

            crust.Pizzas = new List <Pizza> {
                p
            };
            size.Pizzas = new List <Pizza> {
                p
            };
            List <PizzaToppings> pt = new List <PizzaToppings>();

            pvm.SelectedToppings.ForEach(x => pt.Add(new PizzaToppings()
            {
                PizzaId = p.Id, ToppingId = x.Id
            }));
            p.Price         = crust.Price + size.Price + SelectedToppings.Sum(x => x.Price);
            p.PizzaToppings = pt;

            return(_pr.Post(p));
        }
Example #2
0
 private void Factory()
 {
     Toppings = new List <Topping>();
     Crust    = new Crust();
     Size     = new Size();
 }
 public Pizza()
 {
     Toppings = new List <Topping>();
     Crust    = new Crust();
     Size     = new Size();
 }