private static List <Models.API.FacetResult> BuildFacets(ISearchResults searchResult, Tab tab)
        {
            var facetResults = new List <Models.API.FacetResult>();

            foreach (var facetConfiguration in tab.Facets)
            {
                ISearchResultFacet facet = searchResult.Facets.Where(x => x.Definition.FieldName == facetConfiguration.FieldName).FirstOrDefault();
                if (facet != null)
                {
                    FacetResult facetResult = new FacetResult();
                    facetResult.Values    = new List <FacetValue>();
                    facetResult.Name      = facetConfiguration.Name;
                    facetResult.FieldName = facetConfiguration.FieldName;

                    foreach (var facetValue in facet.Values)
                    {
                        FacetValue facetResultValue = new FacetValue();
                        facetResultValue.Count    = facetValue.Count;
                        facetResultValue.Name     = facetValue.Value.ToString();
                        facetResultValue.Selected = facetValue.Selected;
                        facetResultValue.Value    = facetValue.Value.ToString();
                        facetResult.Values.Add(facetResultValue);
                    }
                    facetResult = SortFacetValues(facetConfiguration, facetResult);
                    facetResults.Add(facetResult);
                }
            }
            return(facetResults);
        }
Beispiel #2
0
 private bool IsBoolean(ISearchResultFacet facet)
 {
     if (facet.Values.Count() > 3)
     {
         return(false);
     }
     return(facet.Values.All(v => v.Value is bool || string.IsNullOrWhiteSpace(v.Value?.ToString()) || this.booleanValues.ContainsKey(v.Value?.ToString().ToLowerInvariant())));
 }
Beispiel #3
0
 public bool Format(ISearchResultFacet facet)
 {
     if (!this.IsBoolean(facet))
     {
         return(false);
     }
     this.FormatValues(facet);
     return(true);
 }
Beispiel #4
0
        private void FormatValues(ISearchResultFacet facet)
        {
            foreach (var value in facet.Values)
            {
                if (string.IsNullOrWhiteSpace(value.Value?.ToString()))
                {
                    continue;
                }
                var booleanValue = value.Value as bool? ?? this.booleanValues[value.Value.ToString()];

                value.Title = booleanValue ? DictionaryPhraseRepository.Current.Get("/Indexing/Facets/True", "Yes") : DictionaryPhraseRepository.Current.Get("/Indexing/Facets/False", "No");
            }
        }
Beispiel #5
0
        private void FormatValues(ISearchResultFacet facet)
        {
            foreach (var value in facet.Values)
            {
                if (string.IsNullOrWhiteSpace(value.Value?.ToString()))
                {
                    continue;
                }
                var booleanValue = value.Value as bool? ?? this.booleanValues[value.Value.ToString()];

                value.Title = booleanValue ?
                              DictionaryPhraseRepository.Current.Get(Constants.IndexFields.EnableFacet, Constants.IndexFields.EnableFacetValue) :
                              DictionaryPhraseRepository.Current.Get(Constants.IndexFields.DisableFacet, Constants.IndexFields.DisableFacet);
            }
        }