public PizzaCustomizer(Pizza pizza) { _pizza = pizza; _availableToppings = _pizza.AvailableToppings .AsBindable() .Select(topping => new SelectableTopping(topping)); _selectedToppings = _availableToppings .Where(selectableTopping => selectableTopping.IsSelected) .Select(selectableTopping => selectableTopping.Topping); _healthWarningMessage = _selectedToppings.Count() .Switch() .Case(0, "Surely you would like more toppings?") .Case(toppings => toppings >= 3, "Too many toppings!") .Default( "Perfecto!") .EndSwitch(); _totalPrice = _selectedToppings.Sum(topping => topping.Price).Project(toppingsTotal => toppingsTotal + pizza.BasePrice); }
public Pizza Save(Pizza pizza) { unitOfWork.Session.Save(pizza); return pizza; }