Beispiel #1
0
        protected virtual List <FacetViewModel> GetFacets(GetContentSearchParameter param, WebsiteSearchResult searchResults)
        {
            var facets = new List <FacetViewModel>();
            var labels = WebsiteSearchFacade.GetFacetOptions().ToDictionary(t => t.Item1, t => t.Item2);

            foreach (var f in searchResults.Facets)
            {
                if (f.Hits.Count == 0)
                {
                    continue;
                }

                var facet = new FacetViewModel
                {
                    Label = labels[f.Name],
                    Hits  = new List <FacetHitViewModel>()
                };

                foreach (var hit in f.Hits)
                {
                    facet.Hits.Add(GetFacetHiViewModel(hit, f.Name));
                }

                facets.Add(facet);
            }
            return(facets);
        }
Beispiel #2
0
        protected virtual List <FacetViewModel> GetSelectedFacets(GetContentSearchParameter param, WebsiteSearchResult searchResults)
        {
            var selectedFacets = new Dictionary <string, List <SearchResultFacetHit> >();
            int count          = 0;

            foreach (var f in searchResults.Facets)
            {
                var facets = GetFacetSelection(param, f.Name).ToList();
                count += facets.Count;
                selectedFacets.Add(f.Name, f.Hits.Where(i => facets.Contains(i.Value)).ToList());
            }

            if (count > 0)
            {
                var vm = new List <FacetViewModel>();
                foreach (var f in selectedFacets)
                {
                    var facet = new FacetViewModel()
                    {
                        Label = f.Key,
                        Hits  = new List <FacetHitViewModel>()
                    };

                    foreach (var hit in f.Value)
                    {
                        facet.Hits.Add(GetFacetHiViewModel(hit, f.Key));
                    }

                    vm.Add(facet);
                }
                return(vm);
            }
            return(null);
        }