private async Task <string> RequestRateCardDataFromService(RateCardFilterParameters rateCardFilter) { string rateCardUri = string.Format(rateCardApiUrlFormat, rateCardFilter.SubscriptionId, rateCardFilter.GetFormattedFilter()); var client = Utils.GetAuthenticatedHttpClientForApp(); return(await client.GetStringAsync(rateCardUri)); }
public async Task <RateCard> GetRateCardData(string subscriptionId) { RateCardFilterParameters rateCardFilterParameters = RateCardFilterParameters.GetRateCardFilter(); rateCardFilterParameters.SubscriptionId = subscriptionId; var rateCardData = await GetRateCardData(rateCardFilterParameters); return(rateCardData); }
public async Task <RateCard> GetRateCardData(RateCardFilterParameters rateCardFilter) { string rateCardCacheName = string.Format(RateCardCacheNameFormat, rateCardFilter.OfferId); RateCard rateCardData = MemoryCacher.GetValue(rateCardCacheName) as RateCard; if (rateCardData == null) { var rateCardResponseData = await RequestRateCardDataFromService(rateCardFilter); rateCardData = await Task.Factory.StartNew(() => JsonConvert.DeserializeObject <RateCard>(rateCardResponseData)); //Cache the RateCardData MemoryCacher.Add(rateCardCacheName, rateCardData, DateTime.Now.AddHours(1)); } return(rateCardData); }