Exemplo n.º 1
0
        public SearchFiltersModel(CategoryFiltersModel categoryFilters, PriceFiltersModel priceFilters, HumidorSizeFiltersModel humidorSizeFilters, ColorFiltersModel colorFilters)
        {
            CategoryFilters    = categoryFilters;
            PriceFilters       = priceFilters;
            HumidorSizeFilters = humidorSizeFilters;
            ColorFilters       = colorFilters;

            CalculateFiltersUrl();
        }
Exemplo n.º 2
0
        public SearchViewModel Search()
        {
            //category filters
            var categoryFilters = new CategoryFiltersModel(CategoryID);

            //price filters
            var priceFilters = new PriceFiltersModel(PriceID);

            //humidor size filters
            var humidorSizeFilters = new HumidorSizeFiltersModel(HumidorSizeID);

            //color filters
            var colorFilters = new ColorFiltersModel(ColorID);

            //sorting filters
            var sortingFilters = new SortingFiltersModel(SortID);

            //all search filters
            var searchFilters = new SearchFiltersModel(categoryFilters, priceFilters, humidorSizeFilters, colorFilters);

            //category counts
            categoryFilters.Counts(searchFilters);

            //price counts
            priceFilters.Counts(searchFilters);

            //humidor size counts
            if (categoryFilters.Name == "Humidors")
            {
                humidorSizeFilters.Counts(searchFilters);
            }

            //color counts
            if (categoryFilters.Name == "Lighters")
            {
                colorFilters.Counts(searchFilters);
            }

            //number of items
            var numberOfItems = categoryFilters.Filters[categoryFilters.Id].Count;

            //paging
            var paging = new PagingModel(numberOfItems, Page, ResultsPerPage, searchFilters, sortingFilters);

            //category filter urls
            categoryFilters.Urls(searchFilters, paging, sortingFilters);

            //price filter urls
            priceFilters.Urls(searchFilters, paging, sortingFilters);

            //humidor size filter urls
            humidorSizeFilters.Urls(searchFilters, paging, sortingFilters);

            //color filter urls
            colorFilters.Urls(searchFilters, paging, sortingFilters);

            //sorting urls
            sortingFilters.Urls(searchFilters, paging);

            //search
            IQueryable <ItemModel> items = SearchResults(searchFilters, paging, sortingFilters);

            //view model
            var model = new SearchViewModel(items, paging, searchFilters, sortingFilters);

            return(model);
        }