internal static void SearchDetails(string SourceCity, string DestinationCity, byte totalTicketsNeeded) { bool val = true; if (BusList.Count == 0) { Console.WriteLine("No buses found!!"); } foreach (Bus list in BusList) { if (list.SourceCity.Equals(SourceCity) && list.DestinationCity.Equals(DestinationCity)) { count++; val = false; Console.WriteLine("Travel's Name:{0},Number of Tickets Available:{1}\nPrice Of Ticket:{2},Travels Id:{3}", list.TravelsName, list.AvailableTickets, list.TicketPrice, list.BusId); Console.WriteLine("Choose bus id to book"); int choice = int.Parse(Console.ReadLine()); if ((list.BusId).Equals(choice)) { flag = true; // Console.WriteLine("true"); value = count - 1; count = 0; if (totalTicketsNeeded > BusList[value].AvailableTickets) { Console.WriteLine("Sorry! the ticket availabilty is only " + list.AvailableTickets); } else { list.AvailableTickets = (byte)(list.AvailableTickets - totalTicketsNeeded); if (LoginManager.session == "logged") { Console.WriteLine("Your net amount is " + totalTicketsNeeded * list.TicketPrice); } else { Console.WriteLine("Login to continue"); if (BusManager.PaymentLogin()) { LoginManager.session = "finallogin"; Console.WriteLine("Your net amount is " + totalTicketsNeeded * list.TicketPrice); } } } } break; } } if (val) { Console.WriteLine("OOPS!No Buses found!"); } }
internal void ViewHomePage() { bool count = true; while (count) { Console.WriteLine("------------Homepage----------"); Console.WriteLine("1.Login\n2.SignUp\n3.Search Buses to book ticket\n4.Exit"); try { byte choice = Byte.Parse(Console.ReadLine()); switch (choice) { case 1: LoginManager.CheckLogin(); break; case 2: UserRepositary.SignUp(); break; case 3: BusManager.SearchBus(); break; case 4: count = false; break; default: Console.WriteLine("Enter correct number"); break; } } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine("Enter correct input"); } } }
internal static void AdminOperation() { bool count = true; byte choice; BusManager busManager = new BusManager(); while (count) { Console.WriteLine("1.Add Ticket Details\n2.Update Ticket Details\n3.Search Bus to book ticket\n4.Delete Details\n5.Log out"); choice = byte.Parse(Console.ReadLine()); switch (choice) { case 1: busManager.AddBusDetails(); break; case 2: busManager.ModifyTicketDetail(); break; case 3: BusManager.SearchBus(); break; case 4: busManager.RemoveTicketDetail(); break; case 5: LoginManager.session = "Logged out"; count = false; break; default: Console.WriteLine("enter correct number"); break; } } }
internal static void CheckLogin() { Console.WriteLine("Enter E-mail id"); username = Console.ReadLine(); Console.WriteLine("Enter password"); password = Console.ReadLine(); if (CheckAdmin(username, password)) { if (session == "finallogin") { session = "logged"; Console.WriteLine("Welcome!!! Admin"); } else { session = "logged"; Console.WriteLine("Welcome!!! Admin"); Operation.AdminOperation(); } } else if (UserRepositary.Login(username, password)) { if (session == "finallogin") { session = "logged"; } else { Console.WriteLine("Welcome User!!"); BusManager.SearchBus(); } } else { Console.WriteLine("Login Details not found!! SignUp"); } }