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); }
// This DataTakeOver is stored the movie id that you just entered, and also the random seat public static void SelectDateTime(MovieDetails DataTakeOver, List <MovieSeatDetails> ListOfSeat) { MovieStartTime times = new MovieStartTime(); // This list grab the stored data from the MovieStartTime List <MovieTimeDetails> ListOfTimes = times.ListOfTime(); // This linq used to check the list of times from the movie id that you entered var ListOfTimeID = ListOfTimes.Where(c => c.MovieID == DataTakeOver.MovieID).ToList(); bool select = true; while (select) { Console.WriteLine("Your movie selection: " + DataTakeOver.MovieTitle); Console.WriteLine("Select date and time"); // This method used to print the list of times PrintDateTime(ListOfTimeID); Console.WriteLine(); Console.Write("Enter Id to choose the movie time : "); var movieTime = Console.ReadLine(); // This linq used to check the movie time id is valid or not var checkTimeID = (from c in ListOfTimeID where c.MovieTimeID.ToString() == movieTime select c).SingleOrDefault(); if (checkTimeID != null) { // If the movie id is valid, it will bring the movie time id and random seat to the next class SelectMovieSeatScreen.SelectSeat(checkTimeID, ListOfSeat); } else { Console.WriteLine("Invalid Option"); Thread.Sleep(1000); Console.Clear(); // If entered an invalid option, it will go back to the select movie page SelectMovieScreen.SelectMovie(ListOfSeat); } } }