示例#1
0
        private static void CacheDetails(string subscriptionId, string storageKey, string storageName, string organizationId)
        {
            string signedInUserUniqueId = ClaimsPrincipal.Current.SignedInUserName();

            if (!string.IsNullOrEmpty(storageName) && !string.IsNullOrEmpty(storageKey))
            {
                CacheUserDetails cud = new CacheUserDetails();
                cud.SubscriptionId = subscriptionId;
                cud.StorageName    = storageName;
                cud.OrganizationId = organizationId;
                cud.StorageKey     = storageKey;
                MemoryCacher.Delete(signedInUserUniqueId);
                MemoryCacher.Add(signedInUserUniqueId, cud, DateTime.Now.AddMinutes(15));
            }
        }
示例#2
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);
        }