public void SearchPassengerPasspower(List <Flight> FlightList) { bool isEnter = true, isFind = false; string insertPassengerPartPassport; Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("Search on all flights partial matches or last name"); Console.ForegroundColor = ConsoleColor.DarkGray; do { CleanerManager.CheckBorder(); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("Enter the passpower or part of it: "); Console.ForegroundColor = ConsoleColor.DarkGray; insertPassengerPartPassport = Console.ReadLine(); if (!String.IsNullOrWhiteSpace(insertPassengerPartPassport)) { foreach (Flight itemFlight in FlightList) { if (itemFlight != null) { foreach (Passenger itemPassenger in itemFlight.PassengersList) { if (itemPassenger != null) { string ippp = itemPassenger.PassengerPasspower.ToUpper(); if (ippp.Contains(insertPassengerPartPassport.ToUpper())) { if (!isFind) { Console.WriteLine("---------------------------------------------------------------------------------------------------"); Console.WriteLine("| NF| FirsName | LastName | Birthday |Passport| Sex |Nationality| Class | Cost ticket |"); Console.WriteLine("|---|--------------|----------------|----------|--------|-------|-----------|--------|-------------|"); } isFind = true; Console.Write($"|{itemFlight.FlightNumber,-3}"); Console.WriteLine(itemPassenger.ToString()); } } } isEnter = false; } } if (isFind) { Console.WriteLine("---------------------------------------------------------------------------------------------------"); } else { Console.WriteLine("Matching names not found"); } } else { Console.WriteLine("Entering an empty search canceled"); isEnter = false; } } while (isEnter); }
public void SearchFlightTicket(List <Flight> FlightList) { int tempFlightTicket; Console.WriteLine("Search only for flights in condition 'CheckIn' or 'Delayed'"); bool isEnter = true; do { CleanerManager.CheckBorder(); if (FlightList.FindIndex(x => (x.GetFlightStatus() == "CheckIn" || x.GetFlightStatus() == "Delayed")) == -1) { Console.WriteLine("No matching flights. Press any key."); Console.ReadKey(); break; } Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("Enter the maximum price per economy ticket: "); Console.ForegroundColor = ConsoleColor.DarkGray; bool isCorrectValue = int.TryParse(Console.ReadLine(), out tempFlightTicket); if (isCorrectValue) { List <Flight> tempFlights = FlightList.FindAll(x => (x.GetFlightStatus() == "CheckIn" || x.GetFlightStatus() == "Delayed") && (tempFlightTicket >= x.FlightPriceEconomy)); if (tempFlights.Count > 0) { Console.WriteLine("---------------------------------------------------------------------------------------"); Console.WriteLine("|Direction| Date/Time |Number| City |Terminal/Gate| Status |Free places|"); Console.WriteLine("|---------|----------------|------|---------------|-------------|----------|-----------|"); foreach (Flight item in tempFlights) { Console.WriteLine($"=== Ticket price economy: {item.FlightPriceEconomy,13:C}"); Console.WriteLine(item.ToString()); } Console.WriteLine("----------------------------------------------------------------------------------------"); isEnter = false; } else { Console.WriteLine("No matching flights."); isEnter = false; } } else { Console.WriteLine("The entered price is not digit"); } } while (isEnter); }
public void ManagerMenu(string FlightOrPassenger) { string entiti; if (FlightOrPassenger == "flight") { entiti = " FLIGHT"; printList = x => FlightsManager.PrintList(x); printListDouble = printList; addToList = x => FlightsManager.AddToList(x); deleteFromList = x => FlightsManager.DeleteFromList(x); editList = x => FlightsManager.EditList(x); } else { entiti = "PASSENGER"; printList = x => FlightsManager.PrintList(x); printListDouble = printList; printListDouble += x => PassengerManager.PrintList(x); addToList = x => PassengerManager.AddToList(x); deleteFromList = x => PassengerManager.DeleteFromList(x); editList = x => PassengerManager.EditList(x); } bool isEnter = true; do { Console.CursorLeft = 30; Console.CursorTop = 0; Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine(@"CONTROL MENU {0}S |", entiti); Console.CursorLeft = 30; Console.WriteLine("---------------------------|"); Console.CursorLeft = 30; Console.WriteLine("1 - Print |"); Console.CursorLeft = 30; Console.WriteLine("2 - Add |"); Console.CursorLeft = 30; Console.WriteLine("3 - Delete |"); Console.CursorLeft = 30; Console.WriteLine("4 - Edit |"); Console.CursorLeft = 30; Console.WriteLine("5 - Search |"); Console.CursorLeft = 30; Console.WriteLine("Any key - Back to MAIN menu|"); Console.CursorLeft = 30; Console.WriteLine("---------------------------|"); Console.ForegroundColor = ConsoleColor.DarkGray; switch (Console.ReadKey().KeyChar) { case '1': printListDouble(FlightList); Console.WriteLine("Press any key to back menu"); Console.ReadKey(); CleanerManager.ClearConsole(ClearLineConsole); break; case '2': printList(FlightList); if (addToList(FlightList)) { Console.WriteLine($"{entiti} successfully added"); } else { Console.WriteLine($"{entiti} not added"); } Console.WriteLine("Press any key to back menu"); Console.ReadKey(); CleanerManager.ClearConsole(ClearLineConsole); break; case '3': printList(FlightList); if (deleteFromList(FlightList)) { Console.WriteLine($"{entiti} successfully deleted"); } else { Console.WriteLine($"{entiti} NOT deleted"); } Console.WriteLine("Press any key to back menu"); Console.ReadKey(); CleanerManager.ClearConsole(ClearLineConsole); break; case '4': printList(FlightList); if (editList(FlightList)) { Console.WriteLine($"{entiti} successfully modified"); } else { Console.WriteLine($"{entiti} NOT modified"); } Console.WriteLine("Press any key to back menu"); Console.ReadKey(); CleanerManager.ClearConsole(ClearLineConsole); break; case '5': AirlineSearch.SearchMenu(FlightList); CleanerManager.ClearSearchMenu(); CleanerManager.ClearConsole(ClearLineConsole); break; default: Console.Clear(); isEnter = false; break; } } while (isEnter); }
public void SearchFlightNumber(List <Flight> FlightList) { IManager FlightsManager = new FlightManage(); IManager PassengerManager = new PassengerManage(); bool isEnter = true, isFind = false; int EnterFlightNumber = 0, tempFlightNumber; int stepItem = 0; do { CleanerManager.CheckBorder(); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("Enter flight number: "); Console.ForegroundColor = ConsoleColor.DarkGray; bool isCorrectValue = int.TryParse(Console.ReadLine(), out tempFlightNumber); if (isCorrectValue) { foreach (Flight item in FlightList) { if (item != null && item.FlightNumber != null) { if (item.FlightNumber == tempFlightNumber) { isEnter = false; isFind = true; EnterFlightNumber = stepItem; PassengerManager.PrintList(FlightList, EnterFlightNumber); } } stepItem++; } if (!isFind) { Console.WriteLine("Flight number not found."); Console.ReadKey(); isEnter = false; } } else { Console.WriteLine("The number is not digit"); } } while (isEnter); if (isFind) { Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("What to do with the results: (E)dit, (D)elete, or nothing(Enter) "); Console.ForegroundColor = ConsoleColor.DarkGray; switch (Console.ReadKey().KeyChar) { case 'e': case 'E': Console.WriteLine(); if (PassengerManager.EditList(FlightList, EnterFlightNumber)) { Console.WriteLine("Passenger successfully modified"); } else { Console.WriteLine("Passenger NOT modified"); } Console.WriteLine("Press any key to back menu"); Console.ReadKey(); CleanerManager.ClearConsole(35); break; case 'd': case 'D': Console.WriteLine(); if (PassengerManager.DeleteFromList(FlightList, EnterFlightNumber)) { Console.WriteLine("Passenger successfully deleted"); } else { Console.WriteLine("Passenger NOT deleted"); } Console.WriteLine("Press any key to back menu"); Console.ReadKey(); CleanerManager.ClearConsole(35); break; default: break; } } }