/// <summary>
        /// The default action to render the front-end view
        /// </summary>
        /// <param name="model"/>
        /// <returns/>
        public async new Task <ActionResult> Index(RenderModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            var viewModel = new JobsRssViewModelFromUmbraco(model.Content).BuildModel();

            // Add common properties to the model
            var expiryDate   = new ExpiryDateFromExamine(model.Content.Id, ExamineManager.Instance.SearchProviderCollection["ExternalSearcher"], new ExpiryDateMemoryCache(TimeSpan.FromHours(1)));
            var modelBuilder = new BaseViewModelBuilder(null);
            await modelBuilder.PopulateBaseViewModel(viewModel, model.Content, null,
                                                     expiryDate.ExpiryDate,
                                                     UmbracoContext.Current.InPreviewMode);

            viewModel.Query = new JobSearchQueryConverter(ConfigurationManager.AppSettings["TranslateObsoleteJobTypes"]?.ToUpperInvariant() == "TRUE").ToQuery(Request.QueryString);
            viewModel.Query.ClosingDateFrom = DateTime.Today;
            viewModel.Query.JobsSet         = viewModel.JobsSet;

            var jobsProvider = new JobsDataFromApi(new Uri(ConfigurationManager.AppSettings["JobsApiBaseUrl"]), viewModel.JobsSet, viewModel.JobAdvertPage.Url, new HttpClientProvider(), new MemoryJobCacheStrategy(MemoryCache.Default, Request.QueryString["ForceCacheRefresh"] == "1"));
            var jobs         = await jobsProvider.ReadJobs(viewModel.Query);

            foreach (var job in jobs.Jobs)
            {
                viewModel.Items.Add(job);
            }

            // Jobs close at midnight, so don't cache beyond then.
            // But we reindex every 2 hours, so expire then if it's sooner.
            var untilMidnightTonight = DateTime.Today.ToUkDateTime().AddDays(1) - DateTime.Now.ToUkDateTime();
            var untilNextReindex     = TimeUntilNextReindex();
            var cacheDuration        = untilMidnightTonight > untilNextReindex ? untilNextReindex : untilMidnightTonight;

            new HttpCachingService().SetHttpCacheHeadersFromUmbracoContent(model.Content, UmbracoContext.Current.InPreviewMode, Response.Cache, new[] { expiryDate }, (int)cacheDuration.TotalSeconds);

            return(CurrentTemplate(viewModel));
        }
        /// <summary>
        /// The default action to render the front-end view
        /// </summary>
        /// <param name="model"/>
        /// <returns/>
        public async new Task <ActionResult> Index(RenderModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            var viewModel = new JobSearchResultsViewModelFromUmbraco(model.Content).BuildModel();

            // Add common properties to the model
            var expiryDate   = new ExpiryDateFromExamine(model.Content.Id, ExamineManager.Instance.SearchProviderCollection["ExternalSearcher"], new ExpiryDateMemoryCache(TimeSpan.FromHours(1)));
            var modelBuilder = new BaseViewModelBuilder(new EastSussexGovUKTemplateRequest(Request, webChatSettingsService: new UmbracoWebChatSettingsService(model.Content, new UrlListReader())));
            await modelBuilder.PopulateBaseViewModel(viewModel, model.Content, new ContentExperimentSettingsService(),
                                                     expiryDate.ExpiryDate,
                                                     UmbracoContext.Current.InPreviewMode);

            modelBuilder.PopulateBaseViewModelWithInheritedContent(viewModel,
                                                                   new UmbracoLatestService(model.Content),
                                                                   new UmbracoSocialMediaService(model.Content),
                                                                   null, null, null);

            if (String.IsNullOrEmpty(Request.QueryString["altTemplate"]))
            {
                viewModel.Query = new JobSearchQueryConverter(ConfigurationManager.AppSettings["TranslateObsoleteJobTypes"]?.ToUpperInvariant() == "TRUE").ToQuery(Request.QueryString);
                viewModel.Query.ClosingDateFrom = DateTime.Today;
                viewModel.Query.JobsSet         = viewModel.JobsSet;
                if (Request.QueryString["page"]?.ToUpperInvariant() != "ALL")
                {
                    viewModel.Query.PageSize    = viewModel.Paging.PageSize;
                    viewModel.Query.CurrentPage = viewModel.Paging.CurrentPage;
                }
                viewModel.Metadata.Title = viewModel.Query.ToString();

                var jobsProvider = new JobsDataFromApi(
                    new Uri(ConfigurationManager.AppSettings["JobsApiBaseUrl"]),
                    viewModel.JobsSet,
                    viewModel.JobAdvertPage?.Url,
                    new HttpClientProvider(),
                    new MemoryJobCacheStrategy(MemoryCache.Default, Request.QueryString["ForceCacheRefresh"] == "1")
                    );

                var jobs = await jobsProvider.ReadJobs(viewModel.Query);

                viewModel.Jobs = jobs.Jobs;
                viewModel.Paging.TotalResults = jobs.TotalJobs;
                if (Request.QueryString["page"]?.ToUpperInvariant() == "ALL")
                {
                    viewModel.Paging.PageSize = viewModel.Paging.TotalResults;
                }

                if (!String.IsNullOrEmpty(viewModel.Metadata.RssFeedUrl))
                {
                    var queryString = HttpUtility.ParseQueryString(Request.Url.Query);
                    queryString.Remove("page");
                    if (queryString.HasKeys())
                    {
                        viewModel.Metadata.RssFeedUrl = viewModel.Metadata.RssFeedUrl + "?" + queryString;
                    }
                }
            }

            // Jobs close at midnight, so don't cache beyond then
            var untilMidnightTonight = DateTime.Today.ToUkDateTime().AddDays(1) - DateTime.Now.ToUkDateTime();

            new HttpCachingService().SetHttpCacheHeadersFromUmbracoContent(model.Content, UmbracoContext.Current.InPreviewMode, Response.Cache, new IExpiryDateSource[] { expiryDate, new ExpiryDateFromPropertyValue(model.Content, "latestUnpublishDate_Latest") }, (int)untilMidnightTonight.TotalSeconds);

            return(CurrentTemplate(viewModel));
        }