Ejemplo n.º 1
0
        private Pizza ConvertToDbPizza(domain.Pizza pizza)
        {
            var newPizza = new Pizza();

            newPizza.Crust = _db.Crust.FirstOrDefault(c => c.Name == pizza.Crust.Name);
            newPizza.Size  = _db.Size.FirstOrDefault(s => s.Name == pizza.Size.Name);
            newPizza.Name  = pizza.Name;
            newPizza.Price = pizza.CalculatePrice();

            foreach (var topping in pizza.Toppings)
            {
                newPizza.PizzaTopping.Add(new PizzaTopping()
                {
                    Topping = _db.Toppings.FirstOrDefault(t => t.Name == topping.Name)
                });
            }

            return(newPizza);
        }
Ejemplo n.º 2
0
 public decimal CalculatePrice()
 {
     return(Pizzas.Sum(Pizza => Pizza.CalculatePrice()));
 }