private void UpdateFacets(FacetResults facets, bool bindExistingFacets = false) { var existingSelectedFacets = SearchFacets.Select(e => new FacetGroup() { FacetName = e.FacetName, FacetValues = e.FacetValues.Where(f => f.IsSelected.HasValue && f.IsSelected.Value).ToList() }).ToList(); SearchFacets.Clear(); if (facets != null) { foreach (var result in facets) { SearchFacets.Add(new FacetGroup() { FacetName = result.Key, FacetDisplayName = JobSearchService.FacetDefinitions.ContainsKey(result.Key) ? JobSearchService.FacetDefinitions[result.Key] : result.Key, FacetValues = result.Value.Select(e => new FacetSelection() { FacetValue = e.Value.ToString(), IsSelected = bindExistingFacets && existingSelectedFacets.Any(ef => ef.FacetName == result.Key && ef.FacetValues.Any(fv => fv.FacetValue == e.Value.ToString())), FacetCount = e.Count }) .ToList() }); } } OnPropertyChanged(nameof(ShowFacets)); }