Пример #1
0
        public RefineByBar RefineByBar()
        {
            var bar = new RefineByBar
            {
                ShowLocation = true,
                Filters      = new List <RefineByFilters>()
            };

            if (!string.IsNullOrEmpty(KeepTag) || !string.IsNullOrEmpty(Tag))
            {
                var featured = new RefineByFilters
                {
                    Label     = "Featured events",
                    Mandatory = false,
                    Name      = "tag",
                    Items     = new List <RefineByFilterItems>
                    {
                        new RefineByFilterItems {
                            Label = KeepTag, Checked = !string.IsNullOrEmpty(Tag), Value = KeepTag
                        }
                    }
                };

                bar.Filters.Add(featured);
            }

            var price = new RefineByFilters
            {
                Label     = "Price",
                Mandatory = true,
                Name      = "price",
                Items     = new List <RefineByFilterItems>
                {
                    new RefineByFilterItems {
                        Label = "Paid", Checked = Price == null || Price.Any(p => p == "paid"), Value = "paid"
                    },
                    new RefineByFilterItems {
                        Label = "Free", Checked = Price == null || Price.Any(p => p == "free"), Value = "free"
                    }
                }
            };

            bar.Filters.Add(price);

            return(bar);
        }
Пример #2
0
        public RefineByBar RefineByBar()
        {
            var bar = new RefineByBar
            {
                ShowLocation            = false,
                KeepLocationQueryValues = true,
                MobileFilterText        = "Filter",
                Filters = new List <RefineByFilters>()
            };

            var subCategories = new RefineByFilters
            {
                Label     = "Subcategories",
                Mandatory = false,
                Name      = "subcategories",
                Items     = new List <RefineByFilterItems>()
            };

            if (AvailableSubCategories != null && AvailableSubCategories.Any())
            {
                var distinctSubcategories = AvailableSubCategories.GroupBy(c => c.Slug).Select(c => c.First());

                foreach (var cat in distinctSubcategories.OrderBy(c => c.Name))
                {
                    subCategories.Items.Add(new RefineByFilterItems {
                        Label = cat.Name, Checked = SubCategories.Any(c => c.ToLower() == cat.Slug.ToLower()), Value = cat.Slug
                    });
                }

                bar.Filters.Add(subCategories);
            }

            var getInvolved = new RefineByFilters
            {
                Label     = "Get involved",
                Mandatory = false,
                Name      = "getinvolved",
                Items     = new List <RefineByFilterItems>
                {
                    new RefineByFilterItems {
                        Label = "Volunteering opportunities", Checked = GetInvolved, Value = "yes"
                    }
                }
            };

            bar.Filters.Add(getInvolved);

            if (!string.IsNullOrEmpty(KeepTag) || !string.IsNullOrEmpty(Tag))
            {
                var organisation = new RefineByFilters
                {
                    Label     = "Organisation",
                    Mandatory = false,
                    Name      = "tag",
                    Items     = new List <RefineByFilterItems>
                    {
                        new RefineByFilterItems {
                            Label = OrganisationName, Checked = !string.IsNullOrEmpty(Tag), Value = KeepTag
                        }
                    }
                };

                bar.Filters.Add(organisation);
            }

            return(bar);
        }