public SearchResponse BeginSearch(string sessionId, Request request) { IFlightProvider flightProvider = FlightProviderFactory.GetFlightProvider(); var response = new SearchResponse(); try { Core.Model.Request modelRequest = request.ToModel(); string errorMessage; string searchId = flightProvider.BeginSearch(modelRequest.FromAirport, request.ToAirport, modelRequest.TravelDate, modelRequest.Passengers.GetAdultCount(), modelRequest.Passengers.GetChildCount(), modelRequest.Passengers.GetInfantCount(), out errorMessage); if (!string.IsNullOrEmpty(searchId) && string.IsNullOrEmpty(errorMessage)) { response.IsSuccess = true; response.IsComplete = false; response.SearchId = searchId; } else { response.ErrorMessage = errorMessage; } } catch (Exception exception) { response.ErrorMessage = "Something is not quite right here. Please try again later."; Logger.LogException(exception, Source, "BeginSearch", Severity.Major); } return response; }
public SearchResponse GetSearchResults(string sessionId, string searchId) { var response = new SearchResponse(); using (new ApplicationContextScope(new ApplicationContext())) { ApplicationContext.SetSessionId(sessionId); IFlightProvider flightProvider = FlightProviderFactory.GetFlightProvider(); if (!string.IsNullOrEmpty(searchId)) { try { string errorMessage; bool isComplete; List<Core.Model.AirItinerary> itineraries = flightProvider.GetSearchResults(searchId, out errorMessage, out isComplete); if (!string.IsNullOrEmpty(searchId) && string.IsNullOrEmpty(errorMessage)) { response.IsSuccess = true; response.IsComplete = isComplete; response.SearchId = searchId; response.Itineraries = itineraries.ToDataContract(); } else { response.ErrorMessage = errorMessage; } } catch (Exception exception) { response.ErrorMessage = "Something is not quite right here. Please try again later."; Logger.LogException(exception, Source, "GetSearchResults", Severity.Critical); } } } return response; }