public void CompleteOrder()
 {
     CurrentOrder.PurchaseDate = DateTime.Now;
     _sql.SaveOrder(User.SelectedStore, User, CurrentOrder);
     //      User.Orders.Add(CurrentOrder);
     CurrentOrder = null;
 }
Beispiel #2
0
        static void UserView(User user)
        {
            System.Console.Clear();
            var stay = true;

            do
            {
                System.Console.WriteLine("would you like to view your history (h), place an order (o), or logout (x)?");
                var select = System.Console.ReadLine();
                if (select.Equals("h"))
                {
                    System.Console.Clear();
                    foreach (var o in user.Orders)
                    {
                        System.Console.WriteLine(o.ToString());
                    }
                }
                else if (select.Equals("o"))
                {
                    System.Console.WriteLine("Please select a store by typing its name :");
                    PrintAllStoresWithEF();

                    var SelectedStore = _sql.SelectStore();
                    List <APizzaModel> SelectedPizzas = _client.SelectPizzas();

                    System.Console.Clear();

                    SelectedStore.CreateOrder(SelectedPizzas);
                    user.Orders.Add(SelectedStore.Orders.Last());

                    _sql.SaveOrder(user.Orders.Last());
                    _sql.Update();

                    System.Console.WriteLine("Here are all the pizzas you ordered::");
                    System.Console.WriteLine(user.Orders.Last().ToString());
                }
                else if (select.Equals("x"))
                {
                    stay = false;
                    System.Console.WriteLine("Have a nice day!");
                }
                else
                {
                    System.Console.WriteLine("No valid selection made, please try again");
                }
            } while (stay);
        }