/// <summary> /// Creates the category model. /// </summary> /// <param name="category">The category.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">category</exception> public static CategoryModel CreateCategoryModel(CategoryBase category) { if (category == null) { throw new ArgumentNullException("category"); } var model = new CategoryModel { Category = category }; model.InjectFrom(category); model.LinkedCategories = new List<LinkedCategory>(category.LinkedCategories).ToArray(); model.CatalogOutline = CatalogClient.BuildCategoryOutline(UserHelper.CustomerSession.CatalogId, category); if (category is Category) { var realCat = category as Category; model.CategoryPropertyValues = new List<CategoryPropertyValue>(realCat.CategoryPropertyValues).ToArray(); if (realCat.PropertySet != null && realCat.CategoryPropertyValues != null) { var values = realCat.CategoryPropertyValues; var properties = realCat.PropertySet.PropertySetProperties.SelectMany(x => values.Where(v => v.Name == x.Property.Name && !x.Property.PropertyAttributes.Any(pa => pa.PropertyAttributeName.Equals("Hidden", StringComparison.OrdinalIgnoreCase)) && (!x.Property.IsLocaleDependant || string.Equals(v.Locale, CultureInfo.CurrentUICulture.Name, StringComparison.InvariantCultureIgnoreCase))), (r, v) => CreatePropertyModel(r.Priority, r.Property, v, category)).ToArray(); model.Properties = new PropertiesModel(properties); } } return model; }
public ActionResult SearchResultsWithinCategory(CategoryModel cat, SearchParameters parameters, string name = "Index", CatalogItemSearchCriteria criteria = null, bool savePreferences = true) { criteria = criteria ?? new CatalogItemSearchCriteria(); if (cat != null) { ViewBag.Title = cat.DisplayName; criteria.Outlines.Add(String.Format("{0}*", _catalogClient.BuildCategoryOutline(UserHelper.CustomerSession.CatalogId, cat.Category))); } if (savePreferences) { RestoreSearchPreferences(parameters); } var results = SearchResults(criteria, parameters); return(PartialView(name, results)); }