Beispiel #1
0
        public static void showCart(Account CurrentAccount)
        {
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.White;
            string a = "/// Your Personal Cart," + CurrentAccount.UserName + " ///\n";

            Console.SetCursorPosition((Console.WindowWidth - a.Length) / 2, Console.CursorTop);
            Console.WriteLine(a);
            Console.ResetColor();
            Console.ForegroundColor = ConsoleColor.DarkMagenta;
            string b = "Here are the items you have ordered:\n";

            Console.SetCursorPosition((Console.WindowWidth - b.Length) / 2, Console.CursorTop);
            Console.WriteLine(b);
            Console.ResetColor();
            bool          choosing     = true;
            List <String> jsonContents = new List <String> {
            };
            double totalPrice          = 0;

            //Haalt alle cart items op
            try
            {
                foreach (string line in File.ReadLines(@"cart.json"))
                {
                    jsonContents.Add(line);
                }
                if (jsonContents.Count == 0)
                {
                    Console.ForegroundColor = ConsoleColor.DarkRed;
                    Console.WriteLine("\nThere are no items in your basket, you will be send back to the mainscreen\n");
                    Console.ResetColor();
                    System.Threading.Thread.Sleep(5000);
                    Console.Clear();
                    mainScreen.Show(CurrentAccount);
                }
                var cartList = new List <Cart> {
                };
                foreach (String cartItem in jsonContents)
                {
                    cartList.Add(JsonConvert.DeserializeObject <Cart>(cartItem));
                }
                //Laat alleen de Cart items zien van de ingelogde gebruiker


                foreach (var cart in cartList)
                {
                    if (CurrentAccount.ID == cart.ID)
                    {
                        Console.OutputEncoding = Encoding.UTF8;
                        Console.WriteLine(cart);
                        totalPrice = totalPrice + cart.Price;
                    }
                }
                Console.OutputEncoding = Encoding.UTF8;
                Console.WriteLine("The total price of the items you ordered is: €" + totalPrice + "\n");
            }
            //Als er niks is gevonden
            catch (FileNotFoundException)
            {
                Console.WriteLine("\nNo cart information found!\nPlease add a item to your cart first!\n");
                System.Threading.Thread.Sleep(3500);
                Console.Clear();
                mainScreen.Show(CurrentAccount);
            }


            while (choosing)
            {
                Console.WriteLine("What would you like to do?\n1. Order more\n2. Check out\n3. Return to main menu\n");
                string choice = Console.ReadLine();
                try
                {
                    int number = Int32.Parse(choice);
                    switch (number)
                    {
                    case 1:
                        CateringScreen.showCatering(CurrentAccount);
                        break;

                    case 2:
                        checkout.checkoutScreen(CurrentAccount);

                        break;

                    case 3:
                        mainScreen.Show(CurrentAccount);
                        break;
                    }
                }
                catch (Exception)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("The input you gave is incorrect.\nPlease try a number that is shown on screen.");
                    Console.ResetColor();
                    System.Threading.Thread.Sleep(2500);
                    cartScreen.showCart(CurrentAccount);
                }
            }
        }
        public static void showCatering(Account CurrentAccount)
        {
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Magenta;
            string a = "/// CATERING ///\n";

            Console.SetCursorPosition((Console.WindowWidth - a.Length) / 2, Console.CursorTop);
            Console.WriteLine(a);
            Console.ResetColor();
            Console.ForegroundColor = ConsoleColor.DarkMagenta;
            string b = "Choose one of the available combo deals!!\n";

            Console.SetCursorPosition((Console.WindowWidth - b.Length) / 2, Console.CursorTop);
            Console.WriteLine(b);
            Console.ResetColor();
            bool          choosing     = true;
            List <String> jsonContents = new List <String> {
            };

            try
            {
                foreach (string line in File.ReadLines(@"catering.json"))
                {
                    jsonContents.Add(line);
                }
                if (jsonContents.Count == 0)
                {
                    Console.WriteLine("\nNo catering found!\nPlease create a listing first!\n");
                    System.Threading.Thread.Sleep(3500);
                    Console.Clear();
                    mainScreen.Show(CurrentAccount);
                }
                else
                {
                    var cateList = new List <CateringJSN> {
                    };
                    foreach (String cate in jsonContents)
                    {
                        cateList.Add(JsonConvert.DeserializeObject <CateringJSN>(cate));
                    }
                    foreach (var cate in cateList)
                    {
                        Console.OutputEncoding = Encoding.UTF8;
                        Console.WriteLine(cate);
                    }
                }
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("\nNo catering information found!\nPlease create a listing first!\n");
                System.Threading.Thread.Sleep(3500);
                Console.Clear();
                mainScreen.Show(CurrentAccount);
            }



            Console.WriteLine("Would you like to pre-order a combo deal?\n1. Yes\n2. No\n");
            string options = Console.ReadLine();

            try
            {
                int number = Int32.Parse(options);
                switch (number)
                {
                case 1:

                    while (choosing)
                    {
                        Console.WriteLine("\nPlease enter the combo deal number\n");
                        string choice = Console.ReadLine();
                        int    result = Int32.Parse(choice);


                        var cateList = new List <CateringJSN> {
                        };
                        foreach (String cate in jsonContents)
                        {
                            cateList.Add(JsonConvert.DeserializeObject <CateringJSN>(cate));
                        }
                        foreach (var cate in cateList)
                        {
                            if (cate.ID == result)
                            {
                                Cart   newCartJSON    = new Cart(CurrentAccount.ID, cate.Food + " " + cate.Drink, cate.Price);
                                string strNewCartJSON = JsonConvert.SerializeObject(newCartJSON);
                                using (StreamWriter sw = File.AppendText(@"cart.json"))
                                {
                                    sw.WriteLine(strNewCartJSON);
                                    sw.Close();
                                }
                                Reservation newResJSON    = new Reservation(CurrentAccount.ID, cate.Food + " " + cate.Drink, cate.Price);
                                string      strNewResJSON = JsonConvert.SerializeObject(newResJSON);
                                using (StreamWriter sw = File.AppendText(@"reservations.json"))
                                {
                                    sw.WriteLine(strNewResJSON);
                                    sw.Close();
                                }
                                cateSelecter(result);
                                choosing = false;
                                Console.ForegroundColor = ConsoleColor.DarkMagenta;

                                Console.WriteLine("\nThe combo deal has been added to your basket!\nYou will be send back to the mainscreen");
                                System.Threading.Thread.Sleep(5000);
                                Console.ResetColor();
                                Console.Clear();
                                mainScreen.Show(CurrentAccount);
                                break;
                            }
                        }
                    }

                    break;

                case 2:
                    Console.ForegroundColor = ConsoleColor.DarkRed;
                    Console.WriteLine("\nYou will be send back to the mainscreen\n");
                    Console.ResetColor();
                    System.Threading.Thread.Sleep(2000);
                    Console.Clear();
                    mainScreen.Show(CurrentAccount);
                    break;

                default:
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("The input you gave is incorrect.\nPlease try a number that is shown on screen.");
                    Console.ResetColor();
                    System.Threading.Thread.Sleep(2500);
                    CateringScreen.showCatering(CurrentAccount);
                    break;
                }
            }
            catch (Exception)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("The input you gave is incorrect.\nPlease try a number that is shown on screen.");
                Console.ResetColor();
                System.Threading.Thread.Sleep(2500);
                CateringScreen.showCatering(CurrentAccount);
            }
        }
Beispiel #3
0
        public static void Show(Account CurrentAccount)
        {
            Console.Clear();
            string h;

            Console.ForegroundColor = ConsoleColor.Cyan;
            //TODO: Maak functie dat checkt of je user of guest bent, als je user bent zeg je hoi user anders zeg je gwn hoi
            if (CurrentAccount.UserName == "")
            {
                h = "/// Hello, guest  ///\n";
            }
            else
            {
                h = "/// Hello, " + CurrentAccount.UserName + " ///\n";
            }
            Console.SetCursorPosition((Console.WindowWidth - h.Length) / 2, Console.CursorTop);
            Console.WriteLine(h);
            Console.ResetColor();
            if (CurrentAccount.UserName == "")
            {
                Console.WriteLine("Please enter the number of what you would like to do:\n\n[1] View movies\n[2] Write a review\n[3] View catering\n[4] View Reservations\n[5] View Cart\n[6] Go Back");
            }
            else
            {
                Console.WriteLine("Please enter the number of what you would like to do:\n\n[1] View movies\n[2] Write a review\n[3] View catering\n[4] View Reservations\n[5] View Cart\n[6] Log Out");
            }

            if (CurrentAccount.Role == "Admin")
            {
                Console.WriteLine("[7] Manage movies\n[8] Manage catering\n[9] Manage Schedule\n[10] Remove reviews\n[11] Reset rooms");
            }
            Console.WriteLine("Please enter a number on screen to perform the desired action.");
            bool choosing = true;

            while (choosing)
            {
                string options = Console.ReadLine();
                try
                {
                    int number = Int32.Parse(options);
                    switch (number)
                    {
                    case 1:
                        MovieInfoScreen.showMovies(CurrentAccount);
                        choosing = false;
                        break;

                    case 2:
                        createReviewScreen.createReview(CurrentAccount);
                        choosing = false;
                        break;

                    case 3:
                        CateringScreen.showCatering(CurrentAccount);
                        choosing = false;
                        break;

                    case 4:
                        ReservationsScreen.showRes(CurrentAccount);
                        choosing = false;
                        break;

                    case 5:
                        cartScreen.showCart(CurrentAccount);
                        choosing = false;
                        break;

                    case 6:
                        Console.Clear();
                        if (CurrentAccount.UserName == "")
                        {
                            choosing = false;
                            Console.WriteLine("See you, guest!");
                        }
                        else
                        {
                            choosing = false;
                            Console.WriteLine("See you," + CurrentAccount.UserName);
                        }
                        Program.Main();
                        break;

                    case 7:
                        if (CurrentAccount.Role != "Admin")
                        {
                            Console.WriteLine("Nice try, but you're not getting in that easily ;)");
                        }
                        else
                        {
                            createMovieScreen.createMovie(CurrentAccount);
                            choosing = false;
                        }
                        break;

                    case 8:
                        if (CurrentAccount.Role != "Admin")
                        {
                            Console.WriteLine("Nice try, but you're not getting in that easily ;)");
                        }
                        else
                        {
                            createCateringScreen.CateringCreate(CurrentAccount);
                            choosing = false;
                        }
                        break;

                    case 9:
                        if (CurrentAccount.Role != "Admin")
                        {
                            Console.WriteLine("Nice try, but you're not getting in that easily ;)");
                        }
                        else
                        {
                            createScheduleScreen.createSchedule(CurrentAccount);
                            choosing = false;
                        }
                        break;

                    case 10:
                        if (CurrentAccount.Role != "Admin")
                        {
                            Console.WriteLine("Nice try, but you're not getting in that easily ;)");
                        }
                        else
                        {
                            createReviewScreen.reviewRemover(CurrentAccount);
                            choosing = false;
                        }
                        break;

                    case 11:
                        if (CurrentAccount.Role != "Admin")
                        {
                            Console.WriteLine("Nice try, but you're not getting in that easily ;)");
                        }
                        else
                        {
                            movieRooms.clearRooms();
                            choosing = false;
                        }
                        break;

                    default:
                        choosing = false;
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("The input you gave is incorrect.\nPlease try a number that is shown on screen.");
                        Console.ResetColor();
                        System.Threading.Thread.Sleep(2500);
                        mainScreen.Show(CurrentAccount);
                        break;
                    }
                }
                catch (Exception)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("The input you gave is incorrect.\nPlease try a number that is shown on screen.");
                    Console.ResetColor();
                    System.Threading.Thread.Sleep(2500);
                    mainScreen.Show(CurrentAccount);
                }
            }
        }