/// <summary>
        /// Gets the search result for the search criteria
        /// </summary>
        /// <param name="searchInformation"></param>
        /// <exception cref="FlightsNotAvailableException">Thorws the exception when flights are not available for the given search information</exception>
        /// <returns>Returns the search result for the given search information</returns>
        private SearchResult GetSearchResult(SearchInfo searchInformation)
        {
            SearchResult result = new SearchResult();

            try
            {
                //Get the Schedules from the database based on the search information
                Schedules scheduleCollection = searchDAO.SearchForFlight(searchInformation);
                if (scheduleCollection == null)
                {
                    throw new FlightsNotAvailableException("Flights not available");
                }

                //Add search result for direct flights from the schedules obtained from database
                //based on the search criteria
                try
                {
                    AddSearchResultForDirectFlights(searchInformation, scheduleCollection, result);
                }
                catch (DirectFlightsNotAvailableException)
                {
                }

                //Add search result for connecting flights from the schedules obtained from database
                //based on the search criteria
                try
                {
                    AddSearchResultForConnectingFlights(searchInformation, scheduleCollection, result);
                }
                catch (ConnectingFlightsNotAvailableException)
                {
                }
            }
            catch (SearchFlightDAOException ex)
            {
                throw new FlightsNotAvailableException("Unable to Retrieve Flights", ex);
            }
            catch (FlightsNotAvailableException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new FlightsNotAvailableException("Unable to Retrieve Flights", ex);
            }


            return(result);
        }
Exemple #2
0
        /// <summary>
        /// Gets the search result for the search criteria
        /// </summary>
        /// <param name="searchInformation"></param>
        /// <param name="searchInformation"></param>
        /// <exception cref="FlightsNotAvailableException">Thorws the exception when flights are not available for the given search information</exception>
        /// <returns>Returns the search result for the given search information</returns>
        private SearchResult GetSearchResult(SearchInfo searchInformation, SearchResult result)
        {
            try
            {
                //Get the Schedules from the database based on the search information
                Schedules scheduleCollection = searchDAO.SearchForFlight(searchInformation);
                if (scheduleCollection == null)
                {
                    //CSPRCR17.1 - Log an exception using the LogManager
                    LogMessage message = new LogMessage();
                    message.ClassName       = "SearchManager";
                    message.Message         = "Flights not available";
                    message.MessageDateTime = DateTime.Now;
                    message.MethodName      = "GetSearchResult()";
                    message.ExceptionType   = "FlightsNotAvailableException";

                    Logs.LogManager manager = new Logs.LogManager(Loggers.Event);
                    manager.WriteToLog(message);
                    throw new FlightsNotAvailableException("Flights not available");
                }
                //Add search result for direct flights from the schedules obtained from database
                //based on the search criteria
                try
                {
                    AddSearchResultForDirectFlights(searchInformation, scheduleCollection, result);
                }
                catch (DirectFlightsNotAvailableException)
                {
                }

                //Add search result for connecting flights from the schedules obtained from database
                //based on the search criteria
                try
                {
                    AddSearchResultForConnectingFlights(searchInformation, scheduleCollection, result);
                }
                catch (ConnectingFlightsNotAvailableException)
                {
                    //CSPRCR17.3 - Log an exception using the LogManager
                    LogMessage message = new LogMessage();
                    message.ClassName       = "SearchManager";
                    message.Message         = "Connecting Flights not available";
                    message.MessageDateTime = DateTime.Now;
                    message.MethodName      = "GetSearchResult()";
                    message.ExceptionType   = "ConnectingFlightsNotAvailableException";

                    Logs.LogManager manager = new Logs.LogManager(Loggers.File);
                    manager.WriteToLog(message);
                }
            }
            catch (SearchFlightDAOException ex)
            {
                throw new FlightsNotAvailableException("Unable to Retrieve Flights", ex);
            }
            catch (Exception ex)
            {
                throw new FlightsNotAvailableException("Unable to Retrieve Flights", ex);
            }


            return(result);
        }