コード例 #1
0
        public static void Costumer(User user)
        {
            bool busy    = true;
            var  TheMenu = FoodMenu.getMenu();


            while (busy)
            {
                Console.WriteLine("\nHi, what do you wanna do?\n[1] See menu\n[2] Search menu\n[3] New food order\n[0] Exit...");
                var choice = Program.ChoiceInput(0, 5);
                if (choice == 0)
                {
                    busy = false;
                    Navigation.CustomerNavigation(user);
                    break;
                }
                else if (choice == 1)
                {
                    TheMenu.viewCategory();
                }
                else if (choice == 2)
                {
                    TheMenu.search();
                }
                else if (choice == 3)
                {
                    FoodOrder.Add(user);
                }
            }
        }
コード例 #2
0
        public static void CatererNavigation()
        {
            //navigation system for the caterer with all its options.
            Console.WriteLine("\nPlease pick a option.\n[1] Adjust / look at the menu.\n[2] Look at all orders.\n[3] Look at the expected amount of customers.\n[0] Exit application.");
            int choice = Program.ChoiceInput(0, 3);

            while (choice != 0)
            {
                if (choice == 1)
                {
                    //adjust menu
                    FoodMenu.Caterer();
                }
                else if (choice == 2)
                {
                    //Look at all orders
                    CatererFoodOrder.Caterer();
                }
                else if (choice == 3)
                {
                    //look at expected customers
                    expected.ExpectedCustomers();
                }
                Console.WriteLine("\nPlease pick a option.\n[1] Adjust / look at the menu.\n[2] Look at all orders.\n[3] Look at the expected amount of customers.\n[0] Exit application.");
                choice = Program.ChoiceInput(0, 3);
            }
        }
コード例 #3
0
        public static void Caterer()
        {
            bool busy = true;
            //List<Food> menu = new List<Food>();
            string      fileName = "food.json";
            string      rawJson  = File.ReadAllText(fileName);
            List <Food> mainMenu = JsonConvert.DeserializeObject <List <Food> >(rawJson);
            FoodMenu    menu     = new FoodMenu(mainMenu);

            while (busy)
            {
                while (busy)
                {
                    Console.WriteLine("\nWhat do you wanna do?\n[1] See all avalaible items\n[2] Add a new item\n[3] Edit an item\n[4] Remove an item\n[5] Search for an item\n[6] View by category\n[0] Exit...");
                    int userChoice = Program.ChoiceInput(0, 6);

                    if (userChoice == 0)
                    {
                        busy = false;
                        break;
                    }
                    else if (userChoice == 1)
                    {
                        menu.overview();
                    }
                    else if (userChoice == 2)
                    {
                        menu.addItem();
                    }
                    else if (userChoice == 3)
                    {
                        menu.editItem();
                    }
                    else if (userChoice == 4)
                    {
                        menu.Delete();
                    }
                    else if (userChoice == 5)
                    {
                        menu.search();
                    }
                    else if (userChoice == 6)
                    {
                        menu.viewCategory();
                    }
                    else
                    {
                        Console.WriteLine("Please choose between 1, 2, 3, 4 and 5");
                    }
                }
            }
            string newJson = JsonConvert.SerializeObject(mainMenu);

            File.WriteAllText(fileName, newJson);
        }
コード例 #4
0
        public static void jsonFoodMain()
        {
            string fileName = "food.json";

            string rawJson = File.ReadAllText(@fileName);

            List <Food> menu = JsonConvert.DeserializeObject <List <Food> >(rawJson);

            string newJson = JsonConvert.SerializeObject(menu);

            FoodMenu.Caterer();

            File.WriteAllText(fileName, newJson);
        }
コード例 #5
0
        /*
         * public void displayTime()
         * {
         *  if (Minute < 10)
         *  {
         *      Console.WriteLine(Day + " " + Hour + ": 0" + Minute);
         *  }
         *  else
         *  {
         *      Console.WriteLine(Day + " " + Hour + ":" + Minute);
         *  }
         * }
         */
        public static FoodOrder Add(User user)
        {
            string      fileName = "food.json";
            string      rawJson  = File.ReadAllText(fileName);
            List <Food> menu     = JsonConvert.DeserializeObject <List <Food> >(rawJson);
            var         TheMenu  = new FoodMenu(menu);

            bool        items     = true;
            List <Food> userOrder = new List <Food>();

            while (items)
            {
                bool addFood = true;
                while (addFood)
                {
                    Console.WriteLine("\nEnter the product id or press q to continue...");
                    int    userId;
                    string idStr = Console.ReadLine();
                    if (idStr == "q")
                    {
                        break;
                    }
                    bool sucess = Int32.TryParse(idStr, out userId);

                    if ((sucess) & (userId <= ID.foodMax()) & (userId >= 0))
                    {
                        Console.WriteLine("You selected: ");
                        foreach (var food in menu)
                        {
                            if (food.id == userId)
                            {
                                food.display();
                                userOrder.Add(food);
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("Invalid input");
                        Add(user);
                    }
                }

                if (userOrder.Count == 0)
                {
                    break;
                }
                string s5 = "";
                foreach (var item in userOrder)
                {
                    s5 += item.name;
                }
                Console.WriteLine("When do you want it to be ready?\n");
                string userDay = day();

                Console.WriteLine("The time: ");
                int    userHour   = hour();
                int    userMinute = minute();
                string time       = $"{userHour}:{userMinute}";
                //save to shoppingCart

                string   filename = $"{user.username}-ShoppingCart.json";
                string[] s        = { user.username, "Date: " + userDay, time };
                string   s3       = "";
                for (int i = 0; i < userOrder.Count; i++)
                {
                    Food     order = userOrder[i];
                    string[] s2    = { order.price.ToString(), "Name: " + order.name, "Size: " + order.size, "Category: " + order.category, "Type: " + order.subCategory + "\n" };
                    s3 += order.price.ToString() + order.name + order.size + order.category + order.subCategory + " | ";
                    List <string> myList = new List <string>();
                    myList.AddRange(s);
                    myList.AddRange(s2);
                    s = myList.ToArray();
                }
                if (user.username != "Guest")
                {
                    if (File.Exists(@filename))
                    {
                        string     rawJSON = File.ReadAllText(filename);
                        string[][] data    = JsonConvert.DeserializeObject <string[][]>(rawJSON);
                        Array.Resize(ref data, data.Length + 1);
                        data[data.Length - 1] = s;
                        string shoppingData = JsonConvert.SerializeObject(data);
                        File.WriteAllText(filename, shoppingData);
                    }
                    else
                    {
                        string[][] data         = new string[1][] { s };
                        string     shoppingData = JsonConvert.SerializeObject(data);
                        File.AppendAllText(filename, shoppingData);
                    }
                }
                else
                {
                    user.shoppingCart.Add(s);
                }

                //return to Caterers FoodOrders
                return(new FoodOrder(s5, userDay, time, user.username));
            }
            return(null);
        }