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); }
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); }
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; }