コード例 #1
0
        public IActionResult CreateNewPizza(TempCustomerOrder tmp,
                                            bool Sauce, bool Sausage, bool Pepperoni, bool Cheese, bool Pineapple,
                                            int Size, int Crust, int number)
        {
            if (Size > 100)
            {
                return(View());
            }
            //int size = tmp.Size;
            //string crust = tmp.Crust;
            //bool sauce = tmp.sauce;
            //bool cheese = tmp.cheese;
            //bool pepperoni = tmp.pepperoni;
            //bool sausage = tmp.sausage;
            for (int i = 0; i < number; i++)
            {
                char[] tops = new char[5];
                if (Sauce)
                {
                    tops[0] = '1';
                }
                else
                {
                    tops[0] = '0';
                }
                if (Cheese)
                {
                    tops[1] = '1';
                }
                else
                {
                    tops[1] = '0';
                }
                if (Pepperoni)
                {
                    tops[2] = '1';
                }
                else
                {
                    tops[2] = '0';
                }
                if (Sausage)
                {
                    tops[3] = '1';
                }
                else
                {
                    tops[3] = '0';
                }
                if (Pineapple)
                {
                    tops[4] = '1';
                }
                else
                {
                    tops[4] = '0';
                }

                // add pizza cypher to format code into database model
                PizzaOrderCypher POC = new PizzaOrderCypher();
                POC.setCrust(Crust);
                POC.setSize(Size);
                POC.setToppings(tops);
                POC.getPriceOfPizza();

                // Add Full Order to POC current Customer order.
                ViewBag.id        = tmp.PizzaId + 1;
                FullOrder.storeID = CustomerInfo.StoreId;
                FullOrder.UserID  = CustomerInfo.Id;
                FullOrder.currOrder.Add(POC);

                TempCustomerOrder1 TCO = new TempCustomerOrder1();

                TCO.Toppings = BitFlagConversion.convertFlagArrayToInt(tops);
                TCO.Size     = POC.size;
                TCO.Crust    = POC.crust;
                TCO.CustId   = CustomerInfo.Id;
                TCO.StoreId  = CustomerInfo.StoreId;
                TCO.PizzaId  = new Random().Next(10000000, 100000000);
                TCO.Price    = POC.price;

                _repo_tmp.CreateOrder(TCO);
            }
            return(View());
        }
コード例 #2
0
        /// <summary>
        /// Main Logic for initial choices a Cx can make when they login to the store
        /// </summary>
        /// <param name="username"></param>
        /// <param name="stores"></param>
        /// <param name="locationChoice"></param>
        /// <param name="CurOrd"></param>
        /// <param name="LocationOrderHistory"></param>

        public static void inStoreLogic(string username, string storeName,
                                        Abstractions.IRepositoryCustomer <Customer1> repo,
                                        Abstractions.IRepositoryOrders <Order1> orderRepo,
                                        Abstractions.IRepositoryPizza <Pizza1> pizzaRepo,
                                        Abstractions.IRepositoryStore <Store1> storeRepo)
        {
            var customer = repo.ReadInCustomer();
            var order    = orderRepo.ReadInOrder();
            var pizza    = pizzaRepo.ReadInPizza();
            var store    = storeRepo.ReadInStore();

            // Create new order object to temporarily store the order before confirming it.
            CurrentOrder curOrder      = new CurrentOrder();
            int          inStoreChoice = -1;

            while (inStoreChoice != 0)
            {
                ZZ_PrintLoggedInHeader.printStoreHeaderLoggedIn(username, storeName);
                Console.WriteLine(" |---------------------------------------------------------");
                Console.WriteLine(" | 1. : Order a Pizza.");
                Console.WriteLine(" | 2. : Preview Your Current Order.");
                Console.WriteLine(" | 3. : [ADMIN] Preview All Orders at this Location.");
                Console.WriteLine(" | 0. : Return to Restaurant choice.");
                Console.WriteLine(" |_________________________________________________________");

                inStoreChoice = IntCheck.IntChecker();
                if (inStoreChoice == -1)
                {
                    continue;
                }

                // Pizza Size
                if (inStoreChoice == 1)
                {
                    _e_PizzaMakeChoice.pizzaMakerChoice(username, storeName, curOrder);
                }

                if (inStoreChoice == 2)
                {
                    if (curOrder.pizzasInOrder.Count == 0)
                    {
                        Console.Clear();
                        Console.WriteLine("No pizza's ordered yet!");
                        Thread.Sleep(500);
                    }
                    else
                    {
                        inStoreChoice = 0; // trying to for customer back to store choice after checking out a pizza.
                        // Ordering.CxCurrentOrder.getCustCurrentOrder(username, storeName, curOrder, customer);
                        int num = CxOrdersAtLocation.printCxPrevOrdersAtCurrLoc(username, storeName, curOrder);

                        if (num == 1) // try to read int choice
                        {
                            // Randomize and create new order.
                            Random random  = new Random();
                            int    OrderID = random.Next(1000000000, 2000000000);
                            var    cx      = customer.FirstOrDefault(Cx => Cx.Fname != null && Cx.Fname.Equals(username));
                            var    stor    = store.FirstOrDefault(S => S.StoreName.Equals(storeName));

                            // Tally the complete order first to get the total.
                            double total = 0;
                            foreach (var pi in curOrder.pizzasInOrder)
                            {
                                total += pi.getPriceOfPizza();
                            }

                            // Create new order and submit.
                            Order1 Or = new Order1()
                            {
                                CustId  = cx.Id,
                                OrderId = OrderID,
                                StoreId = stor.Id,
                                Price   = (decimal)total
                            };
                            orderRepo.CreateOrder(Or);

                            foreach (var pie in curOrder.pizzasInOrder)
                            {
                                //
                                char [] tops = Ordering.AddToppingsToPie.getAddToppingsToPie(pie);

                                // Convert toppings int a singular decimal representing a bit flag
                                int    topSet = BitFlagConversion.convertFlagArrayToInt(tops);
                                Pizza1 Cu     = new Pizza1()
                                {
                                    PizzaId  = random.Next(1000000000, 2000000000),
                                    Toppings = topSet,
                                    Crust    = pie.getCrustChoice(),
                                    Size     = pie.getSizeChoice(),
                                    OrderId  = OrderID,
                                    Price    = (decimal)pie.getPriceOfPizza()
                                };

                                pizzaRepo.CreatePizza(Cu);
                            }
                        }
                    }
                }
                // Look at previous order history at current location
                if (inStoreChoice == 3)
                {
                    Ordering.RestaurantOrdersEmployee.AllRestaurantOrders(orderRepo, storeRepo, username, storeName);
                }

                if (inStoreChoice == 0)
                {
                    Console.WriteLine("returning to the previous page...");
                    Thread.Sleep(700);
                    break;
                }
            }
        }