Exemple #1
0
        public ActionResult Search(string q,
                                   int yearMin,
                                   int yearMax,
                                   string currentFacets,
                                   string facetToRemove,
                                   string sortType,
                                   int currentPage = 1)
        {
            var facetHelper = new SearchFacetsHelper(currentFacets);

            if (facetToRemove.Trim().Length > 0)
            {
                facetHelper.RemoveFacet(facetToRemove);
            }

            var response = _searchHelper.Search(q, yearMin, yearMax, facetHelper, sortType, currentPage);

            var model = new SearchViewModel()
            {
                Results       = response.Results,
                Facets        = response.Facets,
                Count         = Convert.ToInt32(response.Count),
                CurrentPage   = currentPage,
                CurrentFacets = facetHelper.SelectionsToString(),
                YearMin       = yearMin,
                YearMax       = yearMax,
                SortType      = sortType,
                SearchQuery   = q,
                FacetHelper   = facetHelper
            };

            return(View("Index", model));
        }
Exemple #2
0
 public SearchViewModel()
 {
     SearchQuery   = string.Empty;
     CurrentPage   = 1;
     SortType      = "miles_low";
     Count         = 0;
     CurrentFacets = string.Empty;
     YearMin       = 2005;
     YearMax       = 2016;
     FacetHelper   = new SearchFacetsHelper(string.Empty);
 }
Exemple #3
0
        public ActionResult Index(string q = "", string sortType = "miles_low", int currentPage = 1)
        {
            var facetHelper = new SearchFacetsHelper("");

            var response = _searchHelper.Search(q, 2005, 2016, facetHelper, sortType, currentPage);

            var model = new SearchViewModel()
            {
                Results     = response.Results,
                Facets      = response.Facets,
                Count       = Convert.ToInt32(response.Count),
                CurrentPage = currentPage,
                SortType    = sortType,
                YearMin     = 2005,
                YearMax     = 2016,
                SearchQuery = q,
                FacetHelper = facetHelper
            };

            return(View(model));
        }