Beispiel #1
0
        private string EncodeRouteValue(string routeValue, SeoUrlKeywordTypes type, string language = null)
        {
            if (!string.IsNullOrEmpty(routeValue))
            {
                routeValue = routeValue.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Last();
                var keyword = routeValue;
                // this.GetKeyword(routeValue, type, language); Sasha: routevalue here is already a keyword

                var client = ClientContext.Clients.CreateBrowseClient();

                if (keyword != null)
                {
                    switch (type)
                    {
                        case SeoUrlKeywordTypes.Store:
                        case SeoUrlKeywordTypes.Item:
                            return routeValue;
                        case SeoUrlKeywordTypes.Category:
                            /*
                            var category =
                                Task.Run(
                                    () =>
                                        client.GetCategoryAsync(routeValue))
                                    .Result.AsWebModel();
                            if (category != null)
                            {
                                return string.Join("/", category.BuildOutline(language).Select(x => x.Value));
                            }
                             * */

                            return routeValue; // routevalue for category is outline
                    }
                }
            }

            return routeValue;
        }
Beispiel #2
0
        protected virtual void EncodeVirtualPath(RouteValueDictionary values, SeoUrlKeywordTypes type)
        {
            var routeValueKey = type.ToString().ToLower();
            var language = values.ContainsKey(Constants.Language)
                ? values[Constants.Language] as string
                : Thread.CurrentThread.CurrentUICulture.Name;

            if (values.ContainsKey(routeValueKey) && values[routeValueKey] != null)
            {
                values[routeValueKey] = this.EncodeRouteValue(values[routeValueKey].ToString(), type, language);
            }
        }