Ejemplo n.º 1
0
        /// <summary>
        /// Runs the activity asynchronously.
        /// </summary>
        /// <param name="sharedContext">The shared context.</param>
        /// <returns>
        /// Next activity to be run or <c>null</c> if last in flow.
        /// </returns>
        public async Task <IActivity> RunAsync(SharedContext sharedContext)
        {
            IBargainFinderMaxData data = sharedContext.GetResult <IBargainFinderMaxData>(InputDataSharedContextKey);

            if (data == null)
            {
                throw new ArgumentException("No data found under key: " + InputDataSharedContextKey);
            }

            var security = await this.sessionPool.TakeSessionAsync(sharedContext.ConversationId);

            var service = this.soapServiceFactory.CreateBargainFinderMaxService(sharedContext.ConversationId, security);
            var request = this.CreateRequest(data);

            sharedContext.AddSerializedResultXML(RequestXmlSharedContextKey, request);
            try
            {
                var result = service.BargainFinderMaxRQ(request);
                sharedContext.AddSerializedResultXML(ResponseXmlSharedContextKey, result);
                EnhancedAirBookData enhancedAirBookData = this.CreateEnhancedAirBookData(result);
                sharedContext.AddResult(EnhancedAirBookActivity.InputDataSharedContextKey, enhancedAirBookData);
                return(new PassengerDetailsContactActivity(this.soapServiceFactory, this.sessionPool));
            }
            catch (Exception ex)
            {
                sharedContext.AddResult(CommonConstants.ExceptionSharedContextKey, ex);
                sharedContext.IsFaulty = true;
                this.sessionPool.ReleaseSession(sharedContext.ConversationId);
                return(null);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates the TPA extensions model.
 /// </summary>
 /// <param name="data">The data.</param>
 /// <returns>The model.</returns>
 private OTA_AirLowFareSearchRQTPA_Extensions CreateTPAExtensions(IBargainFinderMaxData data)
 {
     return(new OTA_AirLowFareSearchRQTPA_Extensions
     {
         IntelliSellTransaction = new TransactionType
         {
             RequestType = new TransactionTypeRequestType
             {
                 Name = data.RequestType ?? string.Empty
             }
         }
     });
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates the travel preferences model.
 /// </summary>
 /// <param name="bargainFinderMaxData">The bargain finder maximum data.</param>
 /// <returns>The model.</returns>
 private AirSearchPrefsType CreateTravelPreferences(IBargainFinderMaxData bargainFinderMaxData)
 {
     return(new AirSearchPrefsType
     {
         TPA_Extensions = new AirSearchPrefsTypeTPA_Extensions
         {
             NumTrips = new NumTripsType
             {
                 Number = 1
             }
         }
     });
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates the TPA extensions model.
 /// </summary>
 /// <param name="data">The data.</param>
 /// <returns>The TPA extensions model.</returns>
 private BargainFinderMaxTPAExtensions CreateTPAExtensions(IBargainFinderMaxData data)
 {
     return(new BargainFinderMaxTPAExtensions
     {
         IntelliSellTransaction = new IntelliSellTransaction
         {
             RequestType = new RequestType
             {
                 Name = data.RequestType ?? string.Empty
             }
         }
     });
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates the request.
 /// </summary>
 /// <param name="data">The data.</param>
 /// <returns>
 /// The request.
 /// </returns>
 private OTA_AirLowFareSearchRQ CreateRequest(IBargainFinderMaxData data)
 {
     return(new OTA_AirLowFareSearchRQ
     {
         Version = "1.9.2",
         ResponseType = "OTA",
         ResponseVersion = "1.9.2",
         OriginDestinationInformation = this.CreateOriginDestinationInfos(data),
         POS = this.CreatePOS(data),
         TPA_Extensions = this.CreateTPAExtensions(data),
         TravelerInfoSummary = this.CreateTravelInfoSummary(data),
         TravelPreferences = this.CreateTravelPreferences(data)
     });
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Creates the request.
 /// </summary>
 /// <param name="data">The data.</param>
 /// <returns>The BargainFinderMax request model.</returns>
 private BargainFinderMaxRQ CreateRequest(IBargainFinderMaxData data)
 {
     return(new BargainFinderMaxRQ
     {
         OTAAirLowFareSearchRQ = new OTAAirLowFareSearchRQ
         {
             OriginDestinationInformation = this.CreateOriginDestinationInfos(data),
             POS = this.CreatePos(data),
             TPAExtensions = this.CreateTPAExtensions(data),
             TravelerInfoSummary = this.CreateTravelInfoSummary(data),
             TravelPreferences = this.CreateTravelPreferences()
         }
     });
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Creates the POS model.
 /// </summary>
 /// <param name="data">The data.</param>
 /// <returns>The model.</returns>
 private SourceType2[] CreatePOS(IBargainFinderMaxData data)
 {
     return(new SourceType2[]
     {
         new SourceType2
         {
             RequestorID = new UniqueID_Type
             {
                 Type = data.RequestorType,
                 CompanyName = new CompanyNameType2
                 {
                     Code = data.RequestorCompanyCode
                 },
                 ID = data.RequestorID
             },
             PseudoCityCode = "7TZA"
         }
     });
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Creates the models containing origin and destination location.
 /// </summary>
 /// <param name="data">The data.</param>
 /// <returns>The models containing origin and destination location.</returns>
 private List <OriginDestinationInformation> CreateOriginDestinationInfos(IBargainFinderMaxData data)
 {
     return(new List <OriginDestinationInformation>
     {
         new OriginDestinationInformation
         {
             DepartureDateTime = data.DepartureDate,
             OriginLocation = new Location
             {
                 LocationCode = data.OriginAirportCode
             },
             DestinationLocation = new Location
             {
                 LocationCode = data.DestinationAirportCode
             },
             RPH = data.RPH
         }
     });
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Creates the travel information summary.
 /// </summary>
 /// <param name="data">The data.</param>
 /// <returns>The summary.</returns>
 private TravelerInfoSummaryType CreateTravelInfoSummary(IBargainFinderMaxData data)
 {
     return(new TravelerInfoSummaryType
     {
         AirTravelerAvail = new TravelerInformationType[]
         {
             new TravelerInformationType
             {
                 PassengerTypeQuantity = new PassengerTypeQuantityType[]
                 {
                     new PassengerTypeQuantityType
                     {
                         Code = data.PassengerTypeCode,
                         Quantity = data.NumberOfPassengers.ToString()
                     }
                 }
             }
         }
     });
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Creates the travel information summary.
 /// </summary>
 /// <param name="data">The data.</param>
 /// <returns>The travel information summary.</returns>
 private TravelerInfoSummary CreateTravelInfoSummary(IBargainFinderMaxData data)
 {
     return(new TravelerInfoSummary
     {
         AirTravelerAvail = new List <AirTravelerAvail>
         {
             new AirTravelerAvail
             {
                 PassengerTypeQuantity = new List <PassengerTypeQuantity>
                 {
                     new PassengerTypeQuantity
                     {
                         Code = data.PassengerTypeCode,
                         Quantity = data.NumberOfPassengers
                     }
                 }
             }
         }
     });
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Creates the POS model..
 /// </summary>
 /// <param name="data">The data.</param>
 /// <returns>The POS model.</returns>
 private POS CreatePos(IBargainFinderMaxData data)
 {
     return(new POS
     {
         Source = new List <Source>
         {
             new Source
             {
                 RequestorID = new RequestorID
                 {
                     ID = data.RequestorID,
                     Type = data.RequestorType,
                     CompanyName = new CompanyCode
                     {
                         Code = data.RequestorCompanyCode
                     }
                 }
             }
         }
     });
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Creates the origin destination information models.
 /// </summary>
 /// <param name="data">The data.</param>
 /// <returns>The models.</returns>
 private OTA_AirLowFareSearchRQOriginDestinationInformation[] CreateOriginDestinationInfos(IBargainFinderMaxData data)
 {
     return(new OTA_AirLowFareSearchRQOriginDestinationInformation[]
     {
         new OTA_AirLowFareSearchRQOriginDestinationInformation
         {
             ItemElementName = ItemChoiceType1.DepartureDateTime,
             Item = data.DepartureDate.ToString("s", CultureInfo.InvariantCulture),
             OriginLocation = new OriginDestinationInformationTypeOriginLocation
             {
                 LocationCode = data.OriginAirportCode
             },
             DestinationLocation = new OriginDestinationInformationTypeDestinationLocation
             {
                 LocationCode = data.DestinationAirportCode
             },
             RPH = data.RPH
         }
     });
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BargainFinderMaxActivity"/> class.
 /// </summary>
 /// <param name="restClient">The REST client.</param>
 /// <param name="data">The input data.</param>
 public BargainFinderMaxActivity(RestClient restClient, IBargainFinderMaxData data)
 {
     this.restClient = restClient;
     this.data       = data;
 }