public void EnsureItemInCart(string pizzaName, int quantity) { for (int i = 0; i < quantity; i++) { _store.AddToCart(_store.PizzaMenuItems.First(item => item.Name == pizzaName)); } }
public PizzaMenuViewModel(IStore store) { _store = store; Title = "Pizza Menu"; Items = store.PizzaMenuItems; InitializeStoreCommand = new Command(async() => await InitializeStore()); ItemTappedCommand = new Command(async(item) => { _store.AddToCart((PizzaMenuItem)item); await NavigateToCartPage(); }); ShowCartCommand = new Command(async() => { await NavigateToCartPage(); }); InitializeStoreCommand.Execute(null); }