Inheritance: SearchResultsSideBarModel
        /// <summary>
        /// Provides a view of features packages that have recently bee updated in the repository group.
        /// Return the three most recently updated packages in the group.
        /// </summary>
        public ActionResult RecentlyUpdated()
        {
            log.DebugFormat("Controller action requested");

            // Create the CKAN search parameters
            var searchParameters = new PackageSearchParameters();
            searchParameters.Groups.Add(SettingsHelper.GetCatalogGroup());

            // Collect the results
            List<Package> packages = CkanHelper.GetAllPackages();

            // Sort by date and take the top 3
            packages = (from package in packages
                                      orderby package.MetadataModified
                                      descending
                                      select package)
                         .Take(3)
                         .ToList();

            SettingsHelper.FilterTitles(packages);

            // Update the results to the top 3
            PackageSearchResponse<Package> response = new PackageSearchResponse<Package>();
            response.Results = packages;
            response.Count = packages.Count;

            // Populate the model
            PackageSearchResultsModel model = new PackageSearchResultsModel();
            model.SearchResults = response;

            // Render the view
            return View(model);
        }
        public ActionResult Index(string q, int? page, string order_by, string tag, string mode)
        {
            log.DebugFormat("Controller action requested");

            this.ConfigureBreadCrumbs(q, tag);

            // Create the CKAN search parameters
            var searchParameters = new PackageSearchParameters();
            searchParameters.AggregateTagCounts = true;
            searchParameters.Query = q;
            searchParameters.Groups.Add(SettingsHelper.GetCatalogGroup());
            
            // Ordering
            if (!String.IsNullOrEmpty(order_by))
            {
                searchParameters.OrderBy = order_by;
            }

            // Tag
            if (!String.IsNullOrEmpty(tag))
            {
                searchParameters.Tags.Add(tag);
            }

            // Build the view model for the results
            PackageSearchResultsModel model = new PackageSearchResultsModel();
            Pager pager = null;

            if (mode == "table")
            {
                model.DisplayMode = ResultsDisplayMode.Table;
                searchParameters.Offset = 0;
                // TODO: In the table mode all results are currently returned and paginated client side.
                // This isn't scalable so this will need looked at in the future (AJAX pagination maybe?)
                searchParameters.Limit = CkanHelper.GetPackageCount();
            }
            else // mode == list (default)
            {
                // Set up the pagination
                int pageNumber = 1;
                if (page != null)
                {
                    pageNumber = (int)page;
                }

                pager = new Pager(pageNumber, SettingsHelper.GetSearchResultsPerPage());

                searchParameters.Offset = pager.RecordOffset;
                searchParameters.Limit = pager.RecordsPerPage;
            }

            // Execute the search
            model.SearchParameters = searchParameters;
            model.SearchResults = CkanHelper.GetClient().SearchPackages<Package>(searchParameters, new CacheSettings(SettingsHelper.GetSearchResultsCacheDuration()));
            
            // Filter the titles
            SettingsHelper.FilterTitles(model.SearchResults.Results);

            // Filter the tags
            model.SearchResults.Tags = TagHelper.FilterTags(model.SearchResults.Tags);

            // Set the pager if we are using it
            if (pager != null)
            {
                // Set the number of records to be paged
                pager.RecordCount = model.SearchResults.Count;      

                // Add the pager to the model
                model.Pager = pager;
            }

            // Render the view
            return View(model);
        }
        /// <summary>
        /// Provides a view of features packages that have recently bee updated in the repository group.
        /// Return the three most recently updated packages in the group.
        /// </summary>
        public ActionResult BrowsePackages()
        {
            log.DebugFormat("Controller action requested");

            var searchParameters = new PackageSearchParameters();
            searchParameters.Groups.Add(SettingsHelper.GetCatalogGroup());

            // Set up the pagination
            Pager pager = new Pager(1, SettingsHelper.GetSearchResultsPerPage());
            searchParameters.Offset = pager.RecordOffset;
            searchParameters.Limit = pager.RecordsPerPage;

            PackageSearchResultsModel model = new PackageSearchResultsModel();
            model.SearchParameters = searchParameters;
            model.SearchResults = CkanHelper.GetClient().SearchPackages<Package>(searchParameters, new CacheSettings(SettingsHelper.GetSearchResultsCacheDuration()));
            SettingsHelper.FilterTitles(model.SearchResults.Results);
            model.Pager = pager;

            // Set the number of records to be paged
            pager.RecordCount = model.SearchResults.Count;

            // Render the view
            return View(model);
        }