/// <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 System.Threading.Tasks.Task <IActivity> RunAsync(SharedContext sharedContext) { IDictionary <string, string> queryDictionary = new Dictionary <string, string> { { "origin", this.data.Origin }, { "destination", this.data.Destination }, { "lengthofstay", this.data.LengthOfStay.ToString() }, { "pointofsalecountry", this.data.PointOfSaleCountry }, { "departuredate", this.data.DepartureDate.ToString("yyyy-MM-dd") } }; if (this.data.MinFare.HasValue) { queryDictionary.Add("minfare", this.data.MinFare.Value.ToString()); } if (this.data.MaxFare.HasValue) { queryDictionary.Add("maxfare", this.data.MaxFare.Value.ToString()); } var httpResponse = await this.restClient.GetAsync <LeadPriceCalendarRS>(Endpoint, queryDictionary); sharedContext.AddRestResult(SharedContextKey, httpResponse, true, ResponseJsonSharedContextKey); sharedContext.AddResult(RequestUrlSharedContextKey, httpResponse.RequestUri); return(this.lastInWorkflow ? null : new InstaFlightsActivity(this.restClient)); }
/// <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) { LeadPriceCalendarRS leadPriceCalendarRS = sharedContext.GetResult(LeadPriceCalendarActivity.SharedContextKey) as LeadPriceCalendarRS; HttpResponse <InstaFlightRS> httpResponse; if (this.data != null) { Dictionary <string, string> queryDictionary = new Dictionary <string, string> { { "origin", this.data.Origin }, { "destination", this.data.Destination }, { "departuredate", this.data.DepartureDate.ToString("yyyy-MM-dd") }, { "returndate", this.data.ReturnDate.ToString("yyyy-MM-dd") } }; httpResponse = await this.restClient.GetAsync <InstaFlightRS>(Endpoint, queryDictionary); } else { string uri = leadPriceCalendarRS.FareInfo.SelectMany(fi => fi.Links).Where(l => l.Rel == "shop").Select(l => l.Href).First(); httpResponse = await this.restClient.GetAsync <InstaFlightRS>(uri); } sharedContext.AddRestResult(SharedContextKey, httpResponse, true, JsonSharedContextKey); sharedContext.AddResult(RequestUriSharedContextKey, httpResponse.RequestUri); return(null); }
/// <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) { BargainFinderMaxRQ request = this.CreateRequest(this.data); sharedContext.AddSerializedResultJson(RequestJsonSharedContextKey, request); var httpResponse = await this.restClient.PostAsync <BargainFinderMaxRQ, BargainFinderMaxRS>(Endpoint, request); sharedContext.AddRestResult <BargainFinderMaxRS>(SharedContextKey, httpResponse, false, ResponseJsonSharedContextKey); sharedContext.AddResult(RequestUrlSharedContextKey, httpResponse.RequestUri); return(null); }