public ActionResult Display(CategoryPathModel category) { var categoryBase = _catalogClient.GetCategoryById(category.Category); if (categoryBase != null && categoryBase.IsActive) { // set the context variable var set = UserHelper.CustomerSession.GetCustomerTagSet(); set.Add(ContextFieldConstants.CategoryId, new Tag(categoryBase.CategoryId)); UserHelper.CustomerSession.CategoryId = categoryBase.CategoryId; var model = CatalogHelper.CreateCategoryModel(categoryBase); if (SiteMaps.Current != null) { var node = SiteMaps.Current.CurrentNode; if (Request.UrlReferrer != null && Request.UrlReferrer.AbsoluteUri.StartsWith(Request.Url.GetLeftPart(UriPartial.Authority))) { if (node != null) { node.RootNode.Attributes["ShowBack"] = true; } if (Request.UrlReferrer.AbsoluteUri.Equals(Request.Url.AbsoluteUri)) { UserHelper.CustomerSession.LastShoppingPage = Url.Content("~/"); } else { UserHelper.CustomerSession.LastShoppingPage = Request.UrlReferrer.AbsoluteUri; } } if (node != null) { //if (node.ParentNode != null && model.CatalogOutline !=null) //{ // node.Attributes["Outline"] = new BrowsingOutline(model.CatalogOutline); //} node.Title = model.DisplayName; } } // display category return(View(GetDisplayTemplate(TargetTypes.Category, categoryBase), model)); } throw new HttpException(404, "Category not found"); }
public ActionResult Display(CategoryPathModel category) { var categoryBase = _catalogClient.GetCategory(category.Category); if (categoryBase != null && categoryBase.IsActive) { // set the context variable var set = UserHelper.CustomerSession.GetCustomerTagSet(); set.Add(ContextFieldConstants.CategoryId, new Tag(categoryBase.CategoryId)); UserHelper.CustomerSession.CategoryId = categoryBase.CategoryId; var model = CatalogHelper.CreateCategoryModel(categoryBase); if (SiteMaps.Current != null) { var node = GetCurrentSiteMapNode(); if (Request.UrlReferrer != null && Request.UrlReferrer.AbsoluteUri.StartsWith(Request.Url.GetLeftPart(UriPartial.Authority))) { if (node != null) { node.RootNode.Attributes["ShowBack"] = true; } if (Request.UrlReferrer.AbsoluteUri.Equals(Request.Url.AbsoluteUri)) { UserHelper.CustomerSession.LastShoppingPage = Url.Content("~/"); } else { UserHelper.CustomerSession.LastShoppingPage = Request.UrlReferrer.AbsoluteUri; } } if (node != null) { if (node.ParentNode != null && model.CatalogOutline !=null) { node.Attributes["Outline"] = new BrowsingOutline(model.CatalogOutline); } node.Title = model.DisplayName; } } // display category return View(GetDisplayTemplate(TargetTypes.Category, categoryBase), model); } throw new HttpException(404, "Category not found"); }
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { var parameters = bindingContext.ValueProvider.GetValue(bindingContext.ModelName); var sp = parameters != null ? parameters.RawValue as CategoryPathModel : null; if (sp == null) { sp = new CategoryPathModel(); var routeData = controllerContext.RouteData; if (routeData.Values.ContainsKey(Constants.Category) && routeData.Values[Constants.Category] != null) { var category = routeData.Values[Constants.Category].ToString(); var lang = routeData.Values.ContainsKey(Constants.Language) ? routeData.Values[Constants.Language] as string : null; sp.Url = SettingsHelper.SeoDecode(category, SeoUrlKeywordTypes.Category, lang); } } return sp; }
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { var parameters = bindingContext.ValueProvider.GetValue(bindingContext.ModelName); var sp = parameters != null ? parameters.RawValue as CategoryPathModel : null; if (sp == null) { sp = new CategoryPathModel(); var routeData = controllerContext.RouteData; if (routeData.Values.ContainsKey(Constants.Category) && routeData.Values[Constants.Category] != null) { var category = routeData.Values[Constants.Category].ToString(); var lang = routeData.Values.ContainsKey(Constants.Language) ? routeData.Values[Constants.Language] as string : null; sp.Url = SettingsHelper.SeoDecode(category, SeoUrlKeywordTypes.Category, lang); } } return(sp); }