static void Main(string[] args) { CinemaMainScreen CinemaApp = new CinemaMainScreen(); MovieStartTime times = new MovieStartTime(); // Open a list to get the stored data from the MovieStartTime List <MovieTimeDetails> ListOfTimes = times.ListOfTime(); // This list is to save the random seat List <MovieSeatDetails> ListOfSeat = new List <MovieSeatDetails>(); Random SeatA = new Random(); for (int y = 0; y < ListOfTimes.Count; y++) { // To check to Hall and give the row. var checkHall = ListOfTimes.Where(c => c.MovieHallID == ListOfTimes[y].MovieHallID).SingleOrDefault(); int check = 0; if (checkHall.MovieHallID == 301 || checkHall.MovieHallID == 304) { check = 4; } if (checkHall.MovieHallID == 302 || checkHall.MovieHallID == 305) { check = 5; } if (checkHall.MovieHallID == 303 || checkHall.MovieHallID == 306) { check = 6; } // Loop Row for (int i = 1; i < check; i++) { // Loop the seat for (int x = 1; x < 11; x++) { // Random the taken and empty SAvail Avail = (SAvail)SeatA.Next(2); MovieSeatDetails SeatList = new MovieSeatDetails { SeatID = +1, SeatNo = i + "," + x, SeatAvail = Avail, MovieTimeID = ListOfTimes[y].MovieTimeID }; ListOfSeat.Add(SeatList); } } } // Bring the random seat data to next class CinemaApp.CinemaTicketApp(ListOfSeat); }
public static void SelectMovie(List <MovieSeatDetails> ListOfSeat) { MoviesList movies = new MoviesList(); // This list stored all movies List <MovieDetails> ListOfMovies = movies.ListOfMovies(); bool menu = true; while (menu) { Console.WriteLine("You login as cinema"); Console.WriteLine("1. Select a movie"); Console.WriteLine("2. Logout"); Console.Write("\nEnter your option : "); var option = Console.ReadLine(); switch (option) { case "1": Console.Clear(); Console.WriteLine("Select a movie"); // This method grab all movies and print it PrintScreen(ListOfMovies); Console.Write("\nEnter movie id : "); var movieID = Console.ReadLine(); // This linq is used to check the movie id valid or not var CheckMID = (from c in ListOfMovies where c.MovieID.ToString() == movieID select c).SingleOrDefault(); if (CheckMID != null) { Console.Clear(); // menu = false , so this will stop the while loop menu = false; // Bring the movie id that is valid and the random seat to the next class SelectMovieTimeScreen.SelectDateTime(CheckMID, ListOfSeat); } else { Console.WriteLine("Invalid Option"); Thread.Sleep(1000); Console.Clear(); } break; case "2": Console.WriteLine("Thanks for using. Have a nice day!"); Thread.Sleep(2000); Console.Clear(); CinemaMainScreen logout = new CinemaMainScreen(); // Go back to the login page logout.CinemaTicketApp(ListOfSeat); break; default: Console.WriteLine("Invalid Option"); Thread.Sleep(1000); Console.Clear(); break; } } }