Example #1
0
        /// <summary>
        /// Convert path to full category path
        /// </summary>
        /// <param name="values">The route values.</param>
        /// <returns></returns>
        protected virtual string ModifyCategoryPath(RouteValueDictionary values)
        {
            var currentPath = values[Constants.Category].ToString();

            if (string.IsNullOrEmpty(currentPath))
            {
                return(null);
            }

            var childCategryEncoded = currentPath.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Last();

            if (string.IsNullOrEmpty(childCategryEncoded))
            {
                return(null);
            }

            var childCategryId = SettingsHelper.SeoDecode(childCategryEncoded, SeoUrlKeywordTypes.Category,
                                                          values.ContainsKey(Constants.Language) ? values[Constants.Language] as string : null);
            var outline =
                new BrowsingOutline(
                    CartHelper.CatalogOutlineBuilder.BuildCategoryOutline(
                        StoreHelper.CustomerSession.CatalogId,
                        CartHelper.CatalogClient.GetCategoryById(childCategryId)));

            return(outline.ToString());
        }
        protected override bool IsMatch(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
        {

            if (!base.IsMatch(httpContext, route, parameterName, values, routeDirection))
            {
                return false;
            }

            if (routeDirection == RouteDirection.UrlGeneration)
            {
                return true;
            }

            var encoded = values[parameterName].ToString();
            var decoded = SettingsHelper.SeoDecode(encoded, SeoUrlKeywordTypes.Category, 
                values.ContainsKey(Constants.Language) ? values[Constants.Language].ToString() : null);

            var childCategryId = decoded.Split(Separator.ToCharArray()).Last();

            var category = CartHelper.CatalogClient.GetCategoryById(childCategryId);

            if (category == null)
            {
                return false;
            }

            var outline = new BrowsingOutline(CartHelper.CatalogOutlineBuilder.BuildCategoryOutline(StoreHelper.CustomerSession.CatalogId, category));

            return ValidateCategoryPath(outline.ToString(), decoded);
        }
        protected override bool IsMatch(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
        {
            if (!base.IsMatch(httpContext, route, parameterName, values, routeDirection))
            {
                return(false);
            }

            if (routeDirection == RouteDirection.UrlGeneration)
            {
                return(true);
            }

            var encoded = values[parameterName].ToString();
            var decoded = SettingsHelper.SeoDecode(encoded, SeoUrlKeywordTypes.Category,
                                                   values.ContainsKey(Constants.Language) ? values[Constants.Language].ToString() : null);

            var childCategryId = decoded.Split(Separator.ToCharArray()).Last();

            var category = CartHelper.CatalogClient.GetCategoryById(childCategryId);

            if (category == null)
            {
                return(false);
            }

            var outline = new BrowsingOutline(CartHelper.CatalogOutlineBuilder.BuildCategoryOutline(StoreHelper.CustomerSession.CatalogId, category));

            return(ValidateCategoryPath(outline.ToString(), decoded));
        }
Example #4
0
        /// <summary>
        /// Convert path to full category path
        /// </summary>
        /// <param name="values">The route values.</param>
        /// <returns></returns>
        protected virtual string ModifyCategoryPath(RouteValueDictionary values)
        {
            var currentPath = values[Constants.Category].ToString();

            if (string.IsNullOrEmpty(currentPath))
                return null;

            var childCategryEncoded = currentPath.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Last();

            if (string.IsNullOrEmpty(childCategryEncoded))
                return null;

            var childCategryCode = SettingsHelper.SeoDecode(childCategryEncoded, SeoUrlKeywordTypes.Category, 
                values.ContainsKey(Constants.Language) ? values[Constants.Language] as string : null);
            var outline =
                new BrowsingOutline(
                    CartHelper.CatalogOutlineBuilder.BuildCategoryOutline(
                        StoreHelper.CustomerSession.CatalogId,
                        CartHelper.CatalogClient.GetCategory(childCategryCode)));

            return outline.ToString();
        }