예제 #1
0
 public void Create(RegOrder order)
 {
     //order.Store = _context.Stores.FirstOrDefault(s => s.Name == order.Store.Name);
     //order.Pizzas = _context.Stores.FirstOrDefault(s => s.Name == order.Store.Name).Orders.FirstOrDefault(o => o.EntityID == order.EntityID).Pizzas.FirstOrDefault(p => p == order.Pizzas);
     _context.Orders.Add(order);
     _context.SaveChanges();
 }
예제 #2
0
 public void Test_OrderContentstype(RegOrder order)
 {
     Assert.IsType <string>(order.Customer.Name);
     Assert.IsType <RegCustomer>(order.Customer);
     Assert.IsType <List <APizza> >(order.Pizzas);
     Assert.IsType <NewYorkStore>(order.Store);
 }
예제 #3
0
        public void Test_PizzaCalc(RegOrder order)
        {
            var TotalPrice = new double();

            foreach (var item in order.Pizzas)
            {
                TotalPrice += item.TotalPrice;
            }

            Assert.Equal(order.TotalCost, TotalPrice);
        }
예제 #4
0
        private static void PrintOrder(RegOrder order)
        {
            List <APizza> pizzas = order.Pizzas;

            Console.WriteLine("Here is your Order and Total");
            var index = -1;

            foreach (var item in pizzas)
            {
                item.CalculatePrice();
                Console.WriteLine($"{"1"} {index += 1} {item.ToString()} {item.TotalPrice}");
            }
            Console.WriteLine($"{"Order Total"} {order.TotalCost}");
        }
예제 #5
0
 public void Test_OrderContents(RegOrder order)
 {
     Assert.NotNull(order.Pizzas);
     Assert.NotNull(order.Customer);
     Assert.NotNull(order.Store);
 }
예제 #6
0
        private static void Run()
        {
            List <AOrder> vieworderlist = new List <AOrder>();
            int           option        = new int();
            var           order         = new RegOrder();
            string        customername  = "";

            do
            {
                Console.WriteLine($"{0}{"-"} {"New Customer"}");
                Console.WriteLine($"{1}{"-"} {"Returning Customer"}");
                Console.WriteLine($"{2}{"-"} {"Store Login"}");
                var valid = int.TryParse(Console.ReadLine(), out int customerselect);
                if (!valid || customerselect > 2)
                {
                    continue;
                }

                if (customerselect == 0)
                {
                    Console.WriteLine($"{"Please type in your name"}");
                    customername   = Console.ReadLine();
                    order.Customer = new RegCustomer()
                    {
                        Name = customername
                    };
                }
                else
                {
                    Console.WriteLine("Please Enter your EntityID");
                    valid = long.TryParse(Console.ReadLine(), out long entityselect);
                    if (!valid)
                    {
                        continue;
                    }
                    order.Customer = FindCustomer(entityselect);
                    //PrintCustomerList();
                    //order.Customer = SelectCustomer();
                }
            } while (order.Customer == null);

            Console.WriteLine("Welcome to PizzaBox" + " " + order.Customer.Name);
            PrintStoreList();
            Console.WriteLine("Please Select a Store");
            order.Store = SelectStore();
            Console.WriteLine("Please Select your Pizzas");
            PrintPizzaList();
            order.Pizzas = SelectPizza();
            PrintOrder(order);

            do
            {
                PrintOptionsList();
                var valid = int.TryParse(Console.ReadLine(), out option);
                if (option == 0)
                {
                    Console.WriteLine("Please select the Pizza you would like to modify");
                    PrintOrder(order);
                    valid = int.TryParse(Console.ReadLine(), out int value);
                    PrintCurrentToppingsList(order.Pizzas[value]);
                    ModifyPizza(order.Pizzas[value]);
                    PrintCurrentToppingsList(order.Pizzas[value]);
                }

                if (option == 1)
                {
                    PrintPizzaList();
                    valid = int.TryParse(Console.ReadLine(), out int value);
                    if (!valid)
                    {
                        continue;
                    }
                    if (value >= _pizzaSingleton.Pizzas.Count)
                    {
                        continue;
                    }
                    order.Pizzas.Add(_pizzaSingleton.Pizzas[value]);
                }

                if (option == 2)
                {
                    Console.WriteLine("Which Pizza would you like to remove");
                    PrintOrder(order);
                    valid = int.TryParse(Console.ReadLine(), out int value);
                    order.Pizzas.Remove(order.Pizzas[value]);
                    PrintOrder(order);
                }

                if (option == 3)
                {
                    //Cashout - Add Order to the Database
                    _orderRepository.Create(order);
                    Console.WriteLine($"{"Name:"} {order.Customer.Name}");
                    Console.WriteLine($"{"Entity ID:"} {order.Customer.EntityID}");
                }

                if (option == 4)
                {
                    //View Current Order
                    PrintOrder(order);
                }

                if (option == 5)
                {
                    //View All Orders
                    PrintAllOrder(_storeSingleton.ViewOrders(order.Store), order.Customer);
                }

                if (option == 6)
                {
                    break;
                }
            } while (option != 6);
        }