Exemplo n.º 1
0
 public void CacheAccessKey(StoreAccessKey key, string accountOrUserId, string storeId)
 {
     _cache.Add("StoreAccessKey:" + accountOrUserId + ":" + storeId,
                key,
                null,
                DateTime.Now.AddMinutes(15.0),
                Cache.NoSlidingExpiration,
                CacheItemPriority.Normal,
                null);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Returns the access key for an account to access a store
        /// </summary>
        /// <param name="accountId">The ID of the account requesting access</param>
        /// <param name="storeId">The store to be accessed</param>
        /// <returns>The access key for the store</returns>
        public StoreAccessKey GetAccountAccessKey(string accountId, string storeId)
        {
            var ret = _cache.LookupAccessKey(accountId, storeId);

            if (ret == null)
            {
                var context = GetAccountsContext();
                var access  =
                    context.StoreAccesss.FirstOrDefault(
                        s => s.AccessStore.Id.Equals(storeId) && s.Grantee.Id.Equals(accountId));
                if (access == null)
                {
                    return(null);
                }
                ret = new StoreAccessKey(access);
                _cache.CacheAccessKey(ret, accountId, storeId);
            }
            return(ret);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns the access key for a user to access a store
        /// </summary>
        /// <param name="userId">The user requesting access</param>
        /// <param name="storeId">The store to be accessed</param>
        /// <returns>The access key for that store</returns>
        public StoreAccessKey GetUserAccessKey(string userId, string storeId)
        {
            var ret = _cache.LookupAccessKey(userId, storeId);

            if (ret == null)
            {
                var context = GetAccountsContext();
                var account = context.Accounts.FirstOrDefault(a => a.UserTokens.Any(t => t.Id.Equals(userId)));
                if (account == null)
                {
                    return(null);
                }
                var access =
                    context.StoreAccesss.FirstOrDefault(
                        s => s.AccessStore.Id.Equals(storeId) && s.Grantee.Equals(account));
                if (access == null)
                {
                    return(null);
                }
                ret = new StoreAccessKey(access);
                _cache.CacheAccessKey(ret, userId, storeId);
            }
            return(ret);
        }
Exemplo n.º 4
0
 public void CacheAccessKey(StoreAccessKey key, string accountOrUserId, string storeId)
 {
     return;
 }