Пример #1
0
 public static IReadOnlyList <TravelAgent> GetStartupAgentList()
 {
     //Double Checked, Thread Safe Singleton returns
     if (_agentList == null)
     {
         lock (SyncLock)
         {
             if (_agentList == null)
             {
                 _agentList = new TravelAgentList();
             }
         }
     }
     return(_agentList._startupAgentList);
 }
Пример #2
0
        public void Login()
        {
            //persistence = new TripPersistence();
            bool success = false;

            while (success == false)
            {
                Console.WriteLine("Please select Travel Agent by typing Agent ID:");
                IReadOnlyList <TravelAgent> startupAgents = TravelAgentList.GetStartupAgentList();
                for (var person = 0; person < startupAgents.Count; person++)
                {
                    Console.WriteLine($"{person + 1}. {startupAgents[person]._name}, {startupAgents[person]._agentID}");
                }

                string input = Console.ReadLine();
                int    id;
                if (int.TryParse(input, out id))
                {
                    for (int i = 0; i < startupAgents.Count; i++)
                    {
                        if (id == startupAgents[i]._agentID)
                        {
                            CurrentAgent = startupAgents[i];
                            Console.WriteLine($"Current Agent = {CurrentAgent._name}");
                            success = true;
                            break;
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Please enter a valid integer:");
                    success = false;
                }
            }
        }