コード例 #1
0
        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));
        }
コード例 #2
0
        public async Task <RateCard> GetRateCardData(string subscriptionId)
        {
            RateCardFilterParameters rateCardFilterParameters = RateCardFilterParameters.GetRateCardFilter();

            rateCardFilterParameters.SubscriptionId = subscriptionId;

            var rateCardData = await GetRateCardData(rateCardFilterParameters);

            return(rateCardData);
        }
コード例 #3
0
        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);
        }