コード例 #1
0
        /// <summary>
        /// Get Atomia Billing account data for current reseller.
        /// </summary>
        public AccountData GetResellerAccountData()
        {
            var         resellerIdentifier = resellerIdentifierProvider.GetResellerIdentifier();
            AccountData resellerData       = null;

            if (resellerIdentifier != null && !string.IsNullOrEmpty(resellerIdentifier.AccountHash))
            {
                resellerData = BillingApi.GetAccountDataByHash(resellerIdentifier.AccountHash);
            }
            else if (resellerIdentifier != null && !string.IsNullOrEmpty(resellerIdentifier.BaseUrl))
            {
                resellerData = BillingApi.GetResellerDataByUrl(resellerIdentifier.BaseUrl);
            }

            if (resellerData == null)
            {
                resellerData = BillingApi.GetDefaultResellerData();
            }

            if (resellerData == null)
            {
                throw new InvalidOperationException("Could not determine reseller AccountData.");
            }

            return(resellerData);
        }
コード例 #2
0
        /// <summary>
        /// Get current reseller account data from cache or get and cache data form base provider.
        /// </summary>
        public AccountData GetResellerAccountData()
        {
            AccountData resellerData       = null;
            var         resellerIdentifier = resellerIdentifierProvider.GetResellerIdentifier();
            var         cacheKey           = "default";

            if (resellerIdentifier != null && !string.IsNullOrEmpty(resellerIdentifier.AccountHash))
            {
                cacheKey = resellerIdentifier.AccountHash;
            }
            else if (resellerIdentifier != null && !string.IsNullOrEmpty(resellerIdentifier.BaseUrl))
            {
                cacheKey = resellerIdentifier.BaseUrl;
            }

            if (!TryGetCachedData(cacheKey, out resellerData))
            {
                resellerData = backingProvider.GetResellerAccountData();
                SetCachedData(cacheKey, resellerData);
            }

            return(resellerData);
        }