Esempio n. 1
0
        /// <summary>
        /// Safely adds a recently viewed key to the CustomerContext.
        /// </summary>
        /// <param name="context">
        /// The context.
        /// </param>
        /// <param name="product">
        /// The product.
        /// </param>
        internal static void AddRecentKey(this ICustomerContext context, IProductContent product)
        {
            var recent = context.DeserializeRecentlyViewed();

            recent.AddKey(product.Key);
            recent.Store(context);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the list of recently viewed items.
        /// </summary>
        /// <param name="context">
        /// The context.
        /// </param>
        /// <param name="siteAlias">
        /// The site alias.
        /// </param>
        /// <returns>
        /// The <see>
        ///         <cref>IEnumerable</cref>
        ///     </see>
        ///     .
        /// </returns>
        internal static IEnumerable <ProductBoxModel> GetRecentlyViewedProducts(this ICustomerContext context, string siteAlias = "Bazaar")
        {
            var keys = context.DeserializeRecentlyViewed().Keys;

            // Get the Merchello helper
            var merchelloHelper = new MerchelloHelper();

            // Get the products as IProductContent
            var listOfIProductContent = keys.Select(
                x =>
                merchelloHelper.TypedProductContent(x))
                                        .Reverse();

            return(BazaarContentHelper.GetProductBoxModels(listOfIProductContent));
        }