コード例 #1
0
        public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary values)
        {
            VirtualPathData result   = null;
            var             tenant   = appContext.CurrentTenant;
            var             localeId = appContext.CurrentLocaleId;

            if (tenant.TenantType == TenantTypeEnum.Store)
            {
                IRouteUrlProductInfo page = null;

                // Get all of the pages
                var pages = routeUrlProductListFactory.GetRouteUrlProductList(tenant.Id);

                if (TryFindMatch(pages, values, out page))
                {
                    if (!string.IsNullOrEmpty(page.VirtualPath))
                    {
                        result = routeUtilities.CreateVirtualPathData(this, page.VirtualPath);
                    }
                }
            }
            return(result);
        }
コード例 #2
0
        private bool TryFindMatch(IEnumerable <IRouteUrlProductInfo> pages, RouteValueDictionary values, out IRouteUrlProductInfo page)
        {
            page = null;
            Guid categoryXProductId = Guid.Empty;
            var  localeId           = (int?)values["localeId"];

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

            if (!Guid.TryParse(Convert.ToString(values["id"]), out categoryXProductId))
            {
                return(false);
            }

            var controller = Convert.ToString(values["controller"]);
            var action     = Convert.ToString(values["action"]);

            if (action == "Details" && controller == "Product")
            {
                page = pages
                       .Where(x => x.CategoryXProductId.Equals(categoryXProductId))
                       .Where(x => x.LocaleId.Equals(localeId))
                       .FirstOrDefault();
                if (page != null)
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #3
0
        private bool TryFindMatch(IEnumerable<IRouteUrlProductInfo> pages, RouteValueDictionary values, out IRouteUrlProductInfo page)
        {
            page = null;
            Guid categoryXProductId = Guid.Empty;
            var localeId = (int?)values["localeId"];

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

            if (!Guid.TryParse(Convert.ToString(values["id"]), out categoryXProductId))
            {
                return false;
            }

            var controller = Convert.ToString(values["controller"]);
            var action = Convert.ToString(values["action"]);

            if (action == "Details" && controller == "Product")
            {
                page = pages
                    .Where(x => x.CategoryXProductId.Equals(categoryXProductId))
                    .Where(x => x.LocaleId.Equals(localeId))
                    .FirstOrDefault();
                if (page != null)
                {
                    return true;
                }
            }
            return false;
        }