コード例 #1
0
        private void RenderSelection(StringBuilder sb, 
            int index,
            long selectedValue,
            string key,
            CategoryFacet facet,
            ProductProperty property,
            List<CategoryFacet> allFacets,
            CategoryPageViewModel model,
            List<BreadCrumbItem> extraCrumbs)
        {
            string selectedName = string.Empty;
            var sn = (from c in property.Choices
                      where c.Id == selectedValue
                      select c.ChoiceName).SingleOrDefault();
            if (sn != null)
            {
                selectedName = sn;
                extraCrumbs.Add(new BreadCrumbItem() { Name = sn });
                ViewBag.MetaDescription += " | " + sn;
                ViewBag.Title += " | " + sn;
            }
            sb.Append("<h6 class=\"filter\">" + property.DisplayName + "</h6> ");

            string baseUrl = model.LocalCategory.RewriteUrl + "?node=" + CategoryFacetKeyHelper.ClearSelfAndChildrenFromKey(key, allFacets, facet.Id);
            sb.Append("<ul class=\"filterselected\"><li>");
            sb.Append(" <a href=\"" + baseUrl + "\">");
            sb.Append(selectedName);
            sb.Append(" [clear]</a></li></ul>");
        }
コード例 #2
0
        protected void btnNew_Click(object sender, ImageClickEventArgs e)
        {
            this.Save();

            CategoryFacetManager manager = CategoryFacetManager.InstantiateForDatabase(MTApp.CurrentRequestContext);

            
            CategoryFacet f = new CategoryFacet();
            f.CategoryId = this.BvinField.Value;
            f.PropertyId = long.Parse(this.lstProperty.SelectedItem.Value);
            f.FilterName = this.lstProperty.SelectedItem.Text;
            f.ParentPropertyId = long.Parse(this.lstParents.SelectedItem.Value);
            f.DisplayMode = CategoryFacetDisplayMode.Single;

            f.SortOrder = manager.FindMaxSortForCategoryParent(this.BvinField.Value, f.ParentPropertyId);

            if (!ExistsAlready(manager, f.CategoryId, f.PropertyId))
            {
                manager.Create(f);
            }
            
            RenderFilterTree();            
        }
コード例 #3
0
        private void RenderNonSelection(StringBuilder sb, int index, long selectedValue, string key,
            CategoryFacet facet, ProductProperty property, List<ProductFacetCount> counts,
            CategoryPageViewModel model)
        {
            sb.Append("<h6 class=\"filter\">" + property.DisplayName + "</h6>");
            sb.Append("<ul class=\"filterselections\">");
            foreach (ProductPropertyChoice c in property.Choices)
            {
                string newKey = CategoryFacetKeyHelper.ReplaceKeyValue(key, index, c.Id);
                string baseUrl = model.LocalCategory.RewriteUrl + "?node=" + newKey;
                string sqlKey = CategoryFacetKeyHelper.ParseKeyToSqlList(newKey);
                ProductFacetCount fc = new ProductFacetCount();
                foreach (ProductFacetCount f in counts)
                {
                    if (f.Key == sqlKey)
                    {
                        fc = f;
                        break;
                    }
                }

                if (fc.ProductCount > 0)
                {
                    sb.Append("<li><a href=\"" + baseUrl + "\">");
                    sb.Append(c.ChoiceName);
                    sb.Append(" (" + fc.ProductCount.ToString() + ")");
                    sb.Append("</a></li>");
                }
            }
            sb.Append("</ul>");
        }