public IncomingCall Answer(string Consultant)
 {
     if (Calls.Count > 0)
     {
         IncomingCall call = Calls.Dequeue();
         call.Consultant = Consultant;
         call.StartTime  = DateTime.Now;
         return(call);
     }
     return(null);
 }
        public void Call(int ClientId)
        {
            IncomingCall call = new IncomingCall()
            {
                Id       = ++_counter,
                ClientId = ClientId,
                CallTime = DateTime.Now
            };

            Calls.Enqueue(call);
        }
Example #3
0
        static void Main(string[] args)
        {
            Random random = new Random();

            CallCenter center = new CallCenter();

            center.Call(1234);
            center.Call(5678);
            center.Call(1468);
            center.Call(9641);

            while (center.AreWaitingCalls())
            {
                IncomingCall call = center.Answer("Marcin");
                Log($" Call #{call.Id} from {call.ClientId} is answered by {call.Consultant}.");
                Thread.Sleep(1000);
                Log($" Call #{call.Id} from {call.ClientId} is ended by {call.Consultant}.");
                Console.Read();
            }
        }
 public void End(IncomingCall call)
 {
     call.EndTime = DateTime.Now;
 }