Exemplo n.º 1
0
        private static AppliedFilterViewModel PopulateAppliedFilterViewModel(
            BaseSearchablePageViewModel searchablePageViewModel,
            string currentFilter
            )
        {
            var appliedFilter = searchablePageViewModel.Filters.Single(
                filter => FilterOptionsContainsFilter(currentFilter, filter.FilterOptions)
                );

            return(new AppliedFilterViewModel(
                       GetFilterDisplayText(currentFilter, appliedFilter.FilterOptions),
                       appliedFilter.FilterName,
                       GetFilterValue(currentFilter, appliedFilter.FilterOptions)
                       ));
        }
Exemplo n.º 2
0
        public IViewComponentResult Invoke(
            BaseSearchablePageViewModel searchablePageViewModel
            )
        {
            var currentFilters = searchablePageViewModel.FilterBy?.Split(FilteringHelper.FilterSeparator).ToList() ??
                                 new List <string>();

            var appliedFilters = currentFilters.Select(
                currentFilter => PopulateAppliedFilterViewModel(searchablePageViewModel, currentFilter)
                );

            var model = new CurrentFiltersViewModel(
                appliedFilters,
                searchablePageViewModel.SearchString,
                searchablePageViewModel.RouteData
                );

            return(View(model));
        }