Ejemplo n.º 1
0
        public static void showMovies(Account CurrentAccount)
        {
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Green;
            string a = "/// MOVIE SELECTION ///\n";

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

            try
            {
                foreach (string line in File.ReadLines(@"movies.json")) //Creates a list with every object from json file
                {
                    jsonContents.Add(line);
                }
                if (jsonContents.Count == 0)
                {
                    Console.WriteLine("\nNo movies found!\nPlease create a listing first!\n");
                    System.Threading.Thread.Sleep(3500);
                    Console.Clear();
                    mainScreen.Show(CurrentAccount);
                }
                else
                {
                    var movieList = new List <Movie> {
                    };
                    foreach (String movie in jsonContents)
                    {
                        movieList.Add(JsonConvert.DeserializeObject <Movie>(movie));
                    }
                    foreach (var movie in movieList)
                    {
                        Console.WriteLine("[" + movie.ID + "]" + "\nTitle: " + movie.Title + "\n");
                    }
                }
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("\nNo movies found!\nPlease create a listing first!\n");
                System.Threading.Thread.Sleep(3500);
                Console.Clear();
                mainScreen.Show(CurrentAccount);
            }
            Console.WriteLine("Would you like to make a reservation and see the reviews of a selected film?\n1. Yes\n2. No\n");
            string options = Console.ReadLine();

            try
            {
                int number = Int32.Parse(options);
                switch (number)
                {
                case 1:
                    try
                    {
                        while (choosing)
                        {
                            Console.WriteLine("\nPlease enter the movie number\n");
                            string choice = Console.ReadLine();
                            int    result = Int32.Parse(choice);


                            var movieList = new List <Movie> {
                            };
                            foreach (String movie in jsonContents)
                            {
                                movieList.Add(JsonConvert.DeserializeObject <Movie>(movie));
                            }
                            foreach (var movie in movieList)
                            {
                                if (movie.ID == result)
                                {
                                    movieSelecter(result);
                                    choosing = false;
                                    Console.WriteLine("\nWould you like to make a reservation?\n1. Yes\n2. No\n");
                                    string opti = Console.ReadLine();
                                    try
                                    {
                                        int  numb         = Int32.Parse(opti);
                                        bool choosingRoom = true;
                                        switch (numb)
                                        {
                                        case 1:
                                            try
                                            {
                                                while (choosingRoom)
                                                {
                                                    Console.WriteLine("Please enter the room number.");
                                                    string chosenRoom = Console.ReadLine();
                                                    int    roomResult = Int32.Parse(chosenRoom);


                                                    List <String> roomJsonContents = new List <String> {
                                                    };
                                                    foreach (string line in File.ReadLines(@"room.json"))
                                                    {
                                                        roomJsonContents.Add(line);
                                                    }
                                                    var roomList = new List <Room> {
                                                    };
                                                    foreach (string seat in roomJsonContents)
                                                    {
                                                        roomList.Add(JsonConvert.DeserializeObject <Room>(seat));
                                                    }
                                                    foreach (var room in roomList)
                                                    {
                                                        if (room.RoomID == roomResult)
                                                        {
                                                            movieRooms.roomScreen(CurrentAccount, movie.Title, movie.ScheduledTime, roomResult);
                                                            choosingRoom = false;
                                                        }
                                                    }
                                                }
                                            }
                                            catch (Exception)
                                            {
                                                Console.ForegroundColor = ConsoleColor.Red;
                                                Console.WriteLine("The input you gave is incorrect.\nPlease try a number that is shown on screen.\nYou'll be send back.");
                                                Console.ResetColor();
                                                System.Threading.Thread.Sleep(3000);
                                                MovieInfoScreen.showMovies(CurrentAccount);
                                            }
                                            break;



                                        case 2:
                                            Console.ForegroundColor = ConsoleColor.DarkRed;
                                            Console.WriteLine("\nYou will be send back.\n");
                                            Console.ResetColor();
                                            System.Threading.Thread.Sleep(2000);
                                            Console.Clear();
                                            showMovies(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);
                                            MovieInfoScreen.showMovies(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.\nYou'll be send back.");
                                        Console.ResetColor();
                                        System.Threading.Thread.Sleep(3000);
                                        MovieInfoScreen.showMovies(CurrentAccount);
                                    }
                                }
                            }
                        }
                    }
                    catch
                    {
                        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);
                        MovieInfoScreen.showMovies(CurrentAccount);
                    }
                    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);
                    MovieInfoScreen.showMovies(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);
                MovieInfoScreen.showMovies(CurrentAccount);
            }
        }
Ejemplo n.º 2
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);
                }
            }
        }
Ejemplo n.º 3
0
        public static void roomScreen(Account CurrentAccount, string movieName, string movieTime, int roomNumber)
        {
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Cyan;
            string h = "Welcome to the seat selection!\n\n";

            Console.SetCursorPosition((Console.WindowWidth - h.Length) / 2, Console.CursorTop);
            Console.WriteLine(h);
            Console.ResetColor();

            List <string> jsonContent = new List <string> {
            };

            foreach (string line in File.ReadLines(@"room.json"))
            {
                jsonContent.Add(line);
            }
            var roomList = new List <Room> {
            };

            foreach (string seat in jsonContent)
            {
                roomList.Add(JsonConvert.DeserializeObject <Room>(seat));
            }
            foreach (Room seat in roomList)
            {
                if (seat.RoomID == roomNumber)
                {
                    Console.WriteLine(seat);     // <<<<<-------------------------- print the room
                }
            }

            Console.WriteLine("What would you like to do?\n1. Reserve a seat.\n2. Go back.\n");
            string options = Console.ReadLine();

            int number = Int32.Parse(options);

            try
            {
                switch (number)
                {
                case 1:

                    var seatList = new List <Seat> {
                    };
                    foreach (var room in roomList)
                    {
                        for (int i = 0; i < room.seatRoom.Length; i++)
                        {
                            for (int j = 0; j < room.seatRoom[i].Length; j++)
                            {
                                if (room.RoomID == roomNumber)
                                {
                                    seatList.Add(room.seatRoom[i][j]);
                                }
                            }
                        }
                    }
                    Console.WriteLine("Please enter which seats you would like to reserve");
                    Console.WriteLine("Please enter the row in which you would like to sit, enter a number.");
                    string xCorInput = Console.ReadLine();
                    int    seatXCor;
                    bool   correctXCor = int.TryParse(xCorInput, out seatXCor);
                    while (!correctXCor)
                    {
                        Console.WriteLine("That was not a correct input for the row, please try again");
                        Console.WriteLine("Please enter the row in which you would like to sit, enter a number.");
                        xCorInput   = Console.ReadLine();
                        correctXCor = int.TryParse(xCorInput, out seatXCor);
                    }

                    Console.WriteLine("Please enter the column in which you would like to sit, enter a number.");
                    string yCorInput = Console.ReadLine();
                    int    seatYCor;
                    bool   correctYCor = int.TryParse(yCorInput, out seatYCor);
                    while (!correctYCor)
                    {
                        Console.WriteLine("That was not a correct input for the column, please try again");
                        Console.WriteLine("Please enter the column in which you would like to sit, enter a number.");
                        yCorInput   = Console.ReadLine();
                        correctYCor = int.TryParse(yCorInput, out seatYCor);
                    }
                    foreach (var seat in seatList)
                    {
                        if (seat.Xcor == seatXCor && seat.Ycor == seatYCor)         // als die bij de seat is die is gekozen
                        {
                            Reservation newResJSON    = new Reservation(CurrentAccount.ID, movieName, seat.Price);
                            string      strNewResJSON = JsonConvert.SerializeObject(newResJSON);
                            using (StreamWriter sw = File.AppendText(@"reservations.json"))
                            {
                                sw.WriteLine(strNewResJSON);
                                sw.Close();
                            }
                            if (seat.Icon == " O " || seat.Icon == " T " || seat.Icon == " * ")
                            {
                                seat.Icon = " - ";         //maak de seat bezet
                                Cart   newCartJSON    = new Cart(CurrentAccount.ID, movieName + $"\nRoom number: {roomNumber}\nSeat Number: {seat.Xcor}, {seat.Ycor}\nMovie Time: {movieTime}", seat.Price);
                                string strNewCartJSON = JsonConvert.SerializeObject(newCartJSON);
                                using (StreamWriter sw = File.AppendText(@"cart.json"))
                                {
                                    sw.WriteLine(strNewCartJSON);
                                    sw.Close();
                                }

                                using (StreamWriter sw = File.CreateText(@"room.json"))
                                {
                                    sw.Close();
                                }
                                foreach (var room in roomList)
                                {
                                    string strnNewSeat = JsonConvert.SerializeObject(room);
                                    using (StreamWriter sw = File.AppendText(@"room.json"))
                                    {
                                        sw.WriteLine(strnNewSeat);
                                        sw.Close();
                                    }
                                }


                                Console.ForegroundColor = ConsoleColor.Blue;
                                Console.WriteLine("Your reservation has been made!\nYou can check for all of your tickets in the cart!\n");

                                Console.ResetColor();
                                Console.ForegroundColor = ConsoleColor.DarkBlue;
                                Console.WriteLine("Type anything if you want to return to the mainscreen.");
                                Console.ResetColor();
                                string confirmation = Console.ReadLine();
                                if (confirmation.ToLower() == "1")
                                {
                                    mainScreen.Show(CurrentAccount);
                                }
                                else
                                {
                                    mainScreen.Show(CurrentAccount);
                                }
                                roomScreen(CurrentAccount, movieName, movieTime, roomNumber);
                            }
                            else
                            {
                                Console.WriteLine("Something went wrong. Please try again.");
                                System.Threading.Thread.Sleep(2000);
                                roomScreen(CurrentAccount, movieName, movieTime, roomNumber);
                            }
                        }
                    }
                    using (StreamWriter sw = File.CreateText(@"room.json"))
                    {
                    }


                    using (StreamWriter sw = File.CreateText(@"room.json"))
                    {
                        sw.WriteLine("");
                    }
                    foreach (Seat seat in seatList)
                    {
                        string strNewRoomJSON = JsonConvert.SerializeObject(seat);
                        using (StreamWriter sw2 = File.AppendText(@"room.json"))
                        {
                            sw2.WriteLine(strNewRoomJSON);
                            sw2.Close();
                        }
                    }



                    break;

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

                default:
                    Console.WriteLine("The input you gave is incorrect.");
                    break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Ejemplo n.º 4
0
        public static void showSchedule(Account CurrentAccount)
        {
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Green;
            string a = "/// FILM SELECTION ///\n";

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

            try
            {
                foreach (string line in File.ReadLines(@"schedules.json"))
                {
                    jsonContents.Add(line);
                }
                if (jsonContents.Count == 0)
                {
                    Console.WriteLine("\nNo Schedule found!\nPlease create a listing first!\n");
                    System.Threading.Thread.Sleep(3500);
                    Console.Clear();
                    mainScreen.Show(CurrentAccount);
                }
                var scheduleList = new List <ScheduleClass> {
                };
                foreach (String schedule in jsonContents)
                {
                    scheduleList.Add(JsonConvert.DeserializeObject <ScheduleClass>(schedule));
                }
                foreach (var schedule in scheduleList)
                {
                    Console.WriteLine(schedule);
                }
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("\nNo movie information found!\nPlease add some movies first!\n");
                System.Threading.Thread.Sleep(3500);
                Console.Clear();
                mainScreen.Show(CurrentAccount);
            }


            Console.WriteLine("Do you want to go to the film selection screen? y/n: ");

            string confirmation = Console.ReadLine();

            if (confirmation.ToLower() == "y")
            {
                MovieInfoScreen.showMovies(CurrentAccount);
            }
            else if (confirmation.ToLower() == "n")
            {
                mainScreen.Show(CurrentAccount);
            }
            else
            {
                showSchedule(CurrentAccount);
            }
        }