public void getAllFlightIDs(string sStartCityCode, string sEndCityCode)
        {
            Console.WriteLine("In getAllFlightIDs({0}, {1})", sStartCityCode, sEndCityCode);
            IFlightQueryCallback    callerProxy = OperationContext.Current.GetCallbackChannel <IFlightQueryCallback>();
            List <Flight_DAL.Route> lstRoutes;

            lock (this)
            {
                lstRoutes = myFlightBLL.getFlightBLLInstance().getFlightsBetweenCities(sStartCityCode, sEndCityCode);
            }
            if (lstRoutes == null)
            {
                callerProxy.OnFlightIDQueryCallback(null);
            }
            else
            {
                var fl = (from r in lstRoutes
                          select r.Flight.FlightID).Distinct();
                if (fl == null)
                {
                    callerProxy.OnFlightIDQueryCallback(null);  //todo - throw SOAPFault
                }
                else
                {
                    callerProxy.OnFlightIDQueryCallback(fl.ToArray());
                }
            }
        }
        public void getListOfDestinations()
        {
            Console.WriteLine("In getListOfDestinations() function .... ");
            IFlightQueryCallback   callerProxy = OperationContext.Current.GetCallbackChannel <IFlightQueryCallback>();
            List <DestinationInfo> lstReturn   = new List <DestinationInfo>();
            List <Destination>     lstDestination;

            lock (this)
            {
                lstDestination = myFlightBLL.getFlightBLLInstance().getAllDestinations();
            }
            if (lstDestination == null)
            {
                callerProxy.onDestinationQueryCallback(null);
            }
            else
            {
                DestinationInfo dInfo;
                foreach (Destination d in lstDestination)
                {
                    dInfo          = new DestinationInfo();
                    dInfo.CityName = d.City;
                    dInfo.CityCode = d.CityCode;
                    lstReturn.Add(dInfo);
                }
                callerProxy.onDestinationQueryCallback(lstReturn.ToArray());
            }
        }
        public void getListOfAllAvailableFlightsBetweenCitiesOnDates(string sStartCityCode, string sEndCityCode,
                                                                     DateTime dtStartDate, DateTime dtEndDate)
        {
            Console.WriteLine("In getListOfAllAvailableFlightsBetweenCitiesOnDates({0}, {1}, {2}, {3})",
                              sStartCityCode, sEndCityCode, dtStartDate.ToString(), dtEndDate.ToString());

            IFlightQueryCallback callerProxy = OperationContext.Current.GetCallbackChannel <IFlightQueryCallback>();
            CultureInfo          provider    = CultureInfo.InvariantCulture;

            //start date time set to 00:00 and end date time component set to 23:59
            dtStartDate = new DateTime(dtStartDate.Year, dtStartDate.Month, dtStartDate.Day, 00, 00, 00);
            dtEndDate   = new DateTime(dtEndDate.Year, dtEndDate.Month, dtEndDate.Day, 23, 59, 59);

            List <FlightInfo>       lstReturn = new List <FlightInfo>();
            List <Flight_DAL.Route> lstRoutes;

            lock (this)
            {
                lstRoutes = myFlightBLL.getFlightBLLInstance().getFlightsBetweenCities(sStartCityCode, sEndCityCode);
            }
            if (lstRoutes == null)
            {
                Console.WriteLine("No routes found");
                callerProxy.onFlightInfoQueryCallback(null);
            }
            else
            {
                Console.WriteLine("Found - {0} routes", lstRoutes.Count);
                DateTime   dtFlight = DateTime.Now;
                FlightInfo fInfo;
                string     sDate;
                foreach (Route r in lstRoutes)
                {
                    dtFlight = dtStartDate;
                    while (dtFlight <= dtEndDate)
                    {
                        Console.WriteLine("Checking route {1} for date - {0}", r.FlightTime, r.RouteID);
                        fInfo                   = new FlightInfo();
                        fInfo.RouteID           = r.RouteID;
                        fInfo.AdultRate         = r.AdultFare;
                        fInfo.ChildRate         = r.ChildFare;
                        fInfo.EndCityCode       = r.Destination1.CityCode;
                        fInfo.EndCityName       = r.Destination1.City;
                        fInfo.StartCityCode     = r.Destination.CityCode;
                        fInfo.StartCityName     = r.Destination.City;
                        fInfo.FlightName        = r.Flight.FlightID;
                        sDate                   = dtFlight.ToString("dd MMM yyyy ") + r.FlightTime;
                        fInfo.FlightTime        = DateTime.ParseExact(sDate, "dd MMM yyyy HH:mm", null); //date+time component
                        fInfo.NumSeatsAvailable = getNumSeatsAvailable(r, fInfo.FlightTime);
                        lstReturn.Add(fInfo);
                        dtFlight = dtFlight.AddDays(1);
                    }
                }

                callerProxy.onFlightInfoQueryCallback(lstReturn.ToArray());
            }
        }
        public void getListOfAllFlightsBetweenCities(string sStartCityCode, string sEndCityCode)
        {
            Console.WriteLine("In getListOfAllFlightsBetweenCities({0}, {1}) function... ", sStartCityCode, sEndCityCode);
            IFlightQueryCallback callerProxy = OperationContext.Current.GetCallbackChannel <IFlightQueryCallback>();
            CultureInfo          provider    = CultureInfo.InvariantCulture;

            List <FlightInfo>       lstReturn = new List <FlightInfo>();
            List <Flight_DAL.Route> lstRoutes;

            lock (this)
            {
                lstRoutes = myFlightBLL.getFlightBLLInstance().getFlightsBetweenCities(sStartCityCode, sEndCityCode);
            }
            if (lstRoutes == null)
            {
                callerProxy.onFlightInfoQueryCallback(null);
            }
            else
            {
                Console.WriteLine("Found - {0} routes", lstRoutes.Count);
                FlightInfo fInfo;
                foreach (Route r in lstRoutes)
                {
                    fInfo               = new FlightInfo();
                    fInfo.RouteID       = r.RouteID;
                    fInfo.AdultRate     = r.AdultFare;
                    fInfo.ChildRate     = r.ChildFare;
                    fInfo.EndCityCode   = r.Destination1.CityCode;
                    fInfo.EndCityName   = r.Destination1.City;
                    fInfo.StartCityCode = r.Destination.CityCode;
                    fInfo.StartCityName = r.Destination.City;
                    fInfo.FlightName    = r.Flight.FlightID;
                    fInfo.FlightTime    = DateTime.ParseExact(r.FlightTime, "HH:mm", null); //only time component
                    Console.WriteLine(fInfo.ToString());
                    lstReturn.Add(fInfo);
                }
                callerProxy.onFlightInfoQueryCallback(lstReturn.ToArray());
            }
        }
        public void checkIfAvailable(string sStartCityCode, string sEndCityCode, DateTime dtFlightDate, int iNumSeats)
        {
            Console.WriteLine("In checkIfAvailable({0}, {1}, {2}, {3}) .... ", sStartCityCode, sEndCityCode, dtFlightDate.ToString(), iNumSeats);
            IFlightQueryCallback    callerProxy = OperationContext.Current.GetCallbackChannel <IFlightQueryCallback>();
            List <Flight_DAL.Route> lstRoutes;

            lock (this)
            {
                lstRoutes = myFlightBLL.getFlightBLLInstance().getFlightsBetweenCities(sStartCityCode, sEndCityCode);
            }
            if (lstRoutes == null)
            {
                callerProxy.onAvailabilityQueryCallback(false); // no seats available, as no route found
            }
            else
            {
                int iReserved;
                //Route r = getRoute(sStartCityCode, sEndCityCode, dtFlightDate);
                Route r = (from ro in lstRoutes
                           where ro.FlightTime.Equals(dtFlightDate.ToString("HH:mm"))
                           select ro).FirstOrDefault();

                if (r == null)
                {
                    callerProxy.onAvailabilityQueryCallback(false); // no seats available, as no route found
                }
                else
                {
                    iReserved = getNumSeatsAvailable(r, dtFlightDate);
                    if (iReserved < iNumSeats)
                    {
                        callerProxy.onAvailabilityQueryCallback(false); //no seats available for the number requested
                        return;
                    }
                }
            }
            callerProxy.onAvailabilityQueryCallback(true);  //seats are available.
        }