Beispiel #1
0
        /// <summary>
        /// Instantiates a wish list
        /// </summary>
        /// <param name="merchelloContext">The merchello context</param>
        /// <param name="customer">The customer associated with the wish list</param>
        /// <returns>The <see cref="IWishList"/></returns>
        internal static IWishList GetWishList(IMerchelloContext merchelloContext, ICustomerBase customer)
        {
            Mandate.ParameterNotNull(merchelloContext, "merchelloContext");
            Mandate.ParameterNotNull(customer, "customer");

            var cacheKey = MakeCacheKey(customer);

            var wishlist = (IWishList)merchelloContext.Cache.RuntimeCache.GetCacheItem(cacheKey);

            if (wishlist != null)
            {
                return(wishlist);
            }

            var customerItemCache = merchelloContext.Services.ItemCacheService.GetItemCacheWithKey(customer, ItemCacheType.Wishlist);

            wishlist = new WishList(customerItemCache, customer);

            merchelloContext.Cache.RuntimeCache.GetCacheItem(cacheKey, () => wishlist);

            return(wishlist);
        }
Beispiel #2
0
        /// <summary>
        /// Instantiates a wish list
        /// </summary>
        /// <param name="merchelloContext">The merchello context</param>
        /// <param name="customer">The customer associated with the wish list</param>
        /// <returns>The <see cref="IWishList"/></returns>
        internal static IWishList GetWishList(IMerchelloContext merchelloContext, ICustomerBase customer)
        {
            Mandate.ParameterNotNull(merchelloContext, "merchelloContext");
            Mandate.ParameterNotNull(customer, "customer");

            var cacheKey = MakeCacheKey(customer);

            var wishlist = (IWishList)merchelloContext.Cache.RuntimeCache.GetCacheItem(cacheKey);

            if (wishlist != null) return wishlist;

            var customerItemCache = merchelloContext.Services.ItemCacheService.GetItemCacheWithKey(customer, ItemCacheType.Wishlist);

            wishlist = new WishList(customerItemCache, customer);

            merchelloContext.Cache.RuntimeCache.GetCacheItem(cacheKey, () => wishlist);

            return wishlist;
        }
Beispiel #3
0
        /// <summary>
        /// Refreshes the runtime cache
        /// </summary>
        /// <param name="merchelloContext">The merchello context</param>
        /// <param name="wishlist">The <see cref="IWishList"/></param>
        public static void Refresh(IMerchelloContext merchelloContext, IWishList wishlist)
        {
            var cacheKey = MakeCacheKey(wishlist.Customer);
            merchelloContext.Cache.RuntimeCache.ClearCacheItem(cacheKey);

            var customerItemCache = merchelloContext.Services.ItemCacheService.GetItemCacheWithKey(wishlist.Customer, ItemCacheType.Wishlist);
            wishlist = new WishList(customerItemCache, wishlist.Customer);
            merchelloContext.Cache.RuntimeCache.GetCacheItem(cacheKey, () => wishlist);
        }