/// <summary> /// The default action to render the front-end view /// </summary> /// <param name="model"></param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">model</exception> public override ActionResult Index(RenderModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } var viewModel = new HomePageViewModelFromUmbraco(model.Content, new UmbracoOnAzureRelatedLinksService(new RemoveMediaDomainUrlTransformer())).BuildModel(); var modelBuilder = new BaseViewModelBuilder(); modelBuilder.PopulateBaseViewModel(viewModel, model.Content, new ContentExperimentSettingsService(), UmbracoContext.Current.InPreviewMode); var jobsData = new JobsLookupValuesFromExamine(ExamineManager.Instance.SearchProviderCollection["PublicJobsLookupValuesSearcher"]); viewModel.JobLocations = Task.Run(async() => await jobsData.ReadLocations()).Result; viewModel.JobTypes = Task.Run(async() => await jobsData.ReadJobTypes()).Result; // 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 List <string>() { "latestUnpublishDate_Latest" }, (int)untilMidnightTonight.TotalSeconds); return(CurrentTemplate(viewModel)); }
// GET: TalentLinkComponent public override ActionResult Index(RenderModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } var viewModel = new SearchViewModelFromUmbraco(model.Content).BuildModel(); var modelBuilder = new BaseViewModelBuilder(); modelBuilder.PopulateBaseViewModel(viewModel, model.Content, new ContentExperimentSettingsService(), UmbracoContext.Current.InPreviewMode); modelBuilder.PopulateBaseViewModelWithInheritedContent(viewModel, new UmbracoLatestService(model.Content), new UmbracoSocialMediaService(model.Content), null, new UmbracoWebChatSettingsService(model.Content, new UrlListReader()), null); viewModel.Metadata.Description = String.Empty; var dataSource = new JobsLookupValuesFromExamine(ExamineManager.Instance.SearchProviderCollection[viewModel.ExamineSearcher]); var locations = Task.Run(async() => await dataSource.ReadLocations()); foreach (var location in locations.Result) { viewModel.Locations.Add(location); } var jobTypes = Task.Run(async() => await dataSource.ReadJobTypes()); foreach (var jobType in jobTypes.Result) { viewModel.JobTypes.Add(jobType); } var salaryRanges = Task.Run(async() => await dataSource.ReadSalaryRanges()); foreach (var salaryRange in salaryRanges.Result) { viewModel.SalaryRanges.Add(salaryRange); } var workPatterns = Task.Run(async() => await dataSource.ReadWorkPatterns()); foreach (var workPattern in workPatterns.Result) { viewModel.WorkPatterns.Add(workPattern); } // 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 List <string>() { "latestUnpublishDate_Latest" }, (int)untilMidnightTonight.TotalSeconds); return(CurrentTemplate(viewModel)); }
/// <summary> /// The default action to render the front-end view /// </summary> /// <param name="model"/> /// <returns/> public override ActionResult Index(RenderModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } var viewModel = new SearchResultsViewModelFromUmbraco(model.Content).BuildModel(); // Add common properties to the model var modelBuilder = new BaseViewModelBuilder(); modelBuilder.PopulateBaseViewModel(viewModel, model.Content, new ContentExperimentSettingsService(), UmbracoContext.Current.InPreviewMode); modelBuilder.PopulateBaseViewModelWithInheritedContent(viewModel, new UmbracoLatestService(model.Content), new UmbracoSocialMediaService(model.Content), null, new UmbracoWebChatSettingsService(model.Content, new UrlListReader()), null); if (String.IsNullOrEmpty(Request.QueryString["altTemplate"])) { viewModel.Query = new JobSearchQueryFactory().CreateFromQueryString(Request.QueryString); viewModel.Query.ClosingDateFrom = DateTime.Today; var jobsProvider = new JobsDataFromExamine(ExamineManager.Instance.SearchProviderCollection[viewModel.ExamineSearcher], new QueryBuilder(new LuceneTokenisedQueryBuilder(), new KeywordsTokeniser(), new LuceneStopWordsRemover(), new WildcardSuffixFilter()), viewModel.JobAdvertPage != null ? new RelativeJobUrlGenerator(viewModel.JobAdvertPage.Url) : null); var jobs = Task.Run(async() => await jobsProvider.ReadJobs(viewModel.Query)).Result; if (String.IsNullOrWhiteSpace(Request.QueryString["page"])) { viewModel.Jobs = jobs.ToPagedList(1, 10); } else if (Request.QueryString["page"].ToUpperInvariant() == "ALL") { viewModel.Jobs = jobs.ToPagedList(1, 10000); } else { int page; Int32.TryParse(Request.QueryString["page"], out page); if (page < 1) { page = 1; } viewModel.Jobs = jobs.ToPagedList(page, 10); } 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; } } var lookupsProvider = new JobsLookupValuesFromExamine(ExamineManager.Instance.SearchProviderCollection[viewModel.ExamineLookupValuesSearcher]); viewModel.JobTypeLookupValues = Task.Run(async() => await lookupsProvider.ReadJobTypes()).Result; viewModel.OrganisationLookupValues = Task.Run(async() => await lookupsProvider.ReadOrganisations()).Result; viewModel.SalaryRangeLookupValues = Task.Run(async() => await lookupsProvider.ReadSalaryRanges()).Result; viewModel.WorkPatternLookupValues = Task.Run(async() => await lookupsProvider.ReadWorkPatterns()).Result; viewModel.LocationLookupValues = Task.Run(async() => await lookupsProvider.ReadLocations()).Result; } // 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 List <string>() { "latestUnpublishDate_Latest" }, (int)untilMidnightTonight.TotalSeconds); return(CurrentTemplate(viewModel)); }
/// <summary> /// Reads the locations. /// </summary> /// <param name="jobsSet">The jobs set.</param> /// <returns></returns> protected async Task <IList <JobsLookupValue> > ReadLocations(JobsSet jobsSet) { var dataSource = new JobsLookupValuesFromExamine(ExamineManager.Instance.SearchProviderCollection[jobsSet + "LookupValuesSearcher"]); return(await dataSource.ReadLocations()); }