Example #1
0
        private static void Run()
        {
            Console.WriteLine("Please enter your user id, or if you are a new user, enter your desired user id");
            string   Name     = Console.ReadLine();
            Customer Customer = _customerSingleton.FindCustomer(Name);

            Console.WriteLine("Enter 1 to place order, 2 to view order history");
            string response = Console.ReadLine();

            if (response == "1")
            {
                myDBContext context = new myDBContext();
                var         order   = new Order();
                Console.WriteLine("Welcome to PizzaBox");
                DisplayStoreMenu();
                order.Customer = new Customer();
                int num = 0;
                SelectStore(ref num);
                order.Store  = _storeSingleton.Stores[num].Name;
                order.Pizzas = SelectPizza();
                Console.WriteLine($"Your total is ${order.GetPrice()}");
                Console.WriteLine($"{order.ToString()}");
                _storeSingleton.Stores[num].orders.Add(order);
                _storeSingleton.finish();
                _customerSingleton.AddOrder(order, Name);
                _customerSingleton.finish();

                var OH = new OrderHistory()
                {
                    StoreName    = _storeSingleton.Stores[num].Name,
                    CustomerName = Name,
                    TotalPrice   = (int)order.GetPrice(),
                };
                OH.SetPriceZero();
                context.Add(OH);
                context.SaveChanges();
            }
            else
            {
                Console.WriteLine(Customer.ToString());
            }
        }