public void AddSafeEntry(SafeEntry SE) { SafeEntryList.Add(SE); }
static void Main(string[] args) { /* create an empty list to store the data */ List <Vistor> vistorList = new List <Vistor>(); List <SHNFacility> sHNFacilityList = new List <SHNFacility>(); List <SafeEntry> safeList = new List <SafeEntry>(); List <BusinessLocation> businessList = new List <BusinessLocation>(); List <TravelEntry> travelList = new List <TravelEntry>(); List <Person> personList = new List <Person>(); List <TraceTogetherToken> tracetogetherList = new List <TraceTogetherToken>(); LoadPerson(personList); LoadBusiness(businessList); /* the progam will keep running until the users type 8 to exit the progam*/ while (true) { try { DisplayMenu(); Console.Write("Enter the option: "); int menuopt = Convert.ToInt32(Console.ReadLine()); /* Display Resident / Vistor from a list and output to the main program */ if (menuopt == 1) { DisplayVistor(personList); } /* calling method from the api to the main program*/ else if (menuopt == 2) { DisplayFacility(sHNFacilityList); } else if (menuopt == 3) { Console.Write("Name of the indiviual: "); string option = Console.ReadLine(); ListPersonParticulars(personList, option); } // calling method from addVistor to add new record and display output. else if (menuopt == 4) { AddVistor(vistorList); } //search the name through the person.csv file else if (menuopt == 5) { Console.Write("Name of the indivual: "); string selectopt = Console.ReadLine(); Search(personList, travelList, sHNFacilityList, selectopt); DisplayFacility(sHNFacilityList); Console.Write("Enter Facility Name: "); string option = Console.ReadLine(); AssignSHNFacility(personList, travelList, sHNFacilityList, option); } // search the name through the person.csv file if found searchSHNCharges method to calculate and display to main program. else if (menuopt == 6) { Console.Write("Name of the indivual: "); string option = Console.ReadLine(); SearchsHNCharges(personList, travelList, sHNFacilityList, option); } else if (menuopt == 7) { Console.Write("Name of the indivual: "); string name = Console.ReadLine(); SearchPerson(personList, name); foreach (BusinessLocation b in businessList) { Console.WriteLine(b); } Console.Write("Enter Branch Code: "); string code = Console.ReadLine(); BusinessLocation result = SearchLocation(businessList, code); if (result != null) { bool full = result.IsFull(code); if (full == true) { Console.WriteLine("Location has reached max capacity. "); } else { result.VisitorsNow += 1; SafeEntry s1 = new SafeEntry(DateTime.Now, result); safeList.Add(s1); Person personresult = SearchPerson(personList, name); personresult.AddSafeEntry(s1); Console.WriteLine("Check In: " + s1.CheckIn); } } else { Console.WriteLine("BranchCode not found. "); } } else if (menuopt == 8) { Console.Write("Name of the indivual: "); string name = Console.ReadLine(); SearchPerson(personList, name); foreach (BusinessLocation b in businessList) { Console.WriteLine(b); } Console.Write("Enter Branch Code: "); string code = Console.ReadLine(); BusinessLocation result2 = SearchLocation(businessList, code); if (result2 != null) { result2.VisitorsNow -= 1; SafeEntry result3 = SearchCheckIn(safeList, result2); if (result3 != null) { result3.PerformCheckOut(code); Console.WriteLine("Check Out: " + result3.CheckOut); safeList.Remove(result3); foreach (SafeEntry s in safeList) { Console.WriteLine(s); } } else { Console.WriteLine("You have not Checked In to this Location. "); } } else { Console.WriteLine("BranchCode not found. "); } } else if (menuopt == 8) { foreach (BusinessLocation b in businessList) { Console.WriteLine(b); } Console.Write("Enter Branch Code: "); string code = Console.ReadLine(); BusinessLocation locationresult = SearchLocation(businessList, code); if (locationresult != null) { Console.Write("Enter New Capacity: "); int capacity = Convert.ToInt32(Console.ReadLine()); locationresult.MaximumCapacity = capacity; } else { Console.WriteLine("BranchCode not found. "); } } else if (menuopt == 9) { Console.Write("Enter Individual Name: "); string name = Console.ReadLine(); Person personresult = SearchPerson(personList, name); Console.Write("Serial Number: "); string serial = Console.ReadLine(); Console.Write("Collection Location: "); string collection = Console.ReadLine(); Console.Write("Expiry Date: "); DateTime expiry = Convert.ToDateTime(Console.ReadLine()); TraceTogetherToken t = new TraceTogetherToken(serial, collection, expiry); tracetogetherList.Add(t); Console.WriteLine("Token has been added to the list sucessfully."); } else { Console.WriteLine("bye"); break; } } catch (FormatException fe) { Console.WriteLine("You have entered an invalid input. Please try again."); Console.WriteLine("Error Message:{0} ", fe.Message); } } }