public IActionResult PlaceOrder()
        {
            ViewBag.Title = "Place an order";

            var pizzasNames = Pizzas.Select(x => x.Name).ToList();

            ViewData["Pizzas"] = pizzasNames;

            ViewData["PizzaSize"] = Enum.GetValues(typeof(PizzaSize)).Cast <PizzaSize>().ToList();

            return(View());
        }
Exemplo n.º 2
0
        public async Task <List <Item> > GetItems()
        {
            List <Item> list = new List <Item>();

            //TODO:

            list.AddRange(await Pizzas.Select(async p => await ItemFormatter.GetItem(p)).WhenAll());
            list.AddRange(await Sides.Select(async s => await ItemFormatter.GetItemFromSideId(s)).WhenAll());
            list.AddRange(await PreMadePizzas.Select(async p => await ItemFormatter.GetItemFromPizzaId(p)).WhenAll());
            if (list.Count == 0)
            {
                list.Add(ItemFormatter.EmptyItem());
            }
            return(list);
        }
Exemplo n.º 3
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Pizzas.Clear();

                var client = new HttpClient();
                HttpResponseMessage httpResponseMessage = await client.GetAsync("https://www.olo.com/pizzas.json");

                if (httpResponseMessage.IsSuccessStatusCode)
                {
                    var content = await httpResponseMessage.Content.ReadAsStringAsync();

                    Pizzas = JsonConvert.DeserializeObject <ObservableCollection <Pizza> >(content);

                    var tmp =
                        from p in Pizzas.Select(pt => string.Join(", ", pt.Toppings.OrderBy(t => t).ToList <string>()))
                        group p by p
                        into g
                        orderby g.Count() descending
                        select new PizzaFavorite
                    {
                        Toppings = g.Key, Count = g.Count()
                    };

                    PizzaFavorites = new ObservableCollection <PizzaFavorite>(tmp.Take(20));
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 4
0
 public static IEnumerable <SelectListItem> PizzasToSelectListItems()
 {
     return(Pizzas.Select(x => new SelectListItem(x.Name, x.Id.ToString())));
 }