protected TListModel SimilarJobs <TListModel>(IMember member, Guid jobAdId, JobAdsPresentationModel presentation) where TListModel : JobAdSearchListModel, new() { presentation = PreparePresentationModel(presentation); // Search. var range = presentation.Pagination.ToRange(); var results = _executeJobAdSearchCommand.SearchSimilar(member, jobAdId, presentation.Pagination.ToRange()); return(new TListModel { Criteria = null, Presentation = presentation, ListType = JobAdListType.SimilarJobs, Results = new JobAdListResultsModel { TotalJobAds = results.Results.TotalMatches, JobAdIds = results.Results.JobAdIds.SelectRange(range).ToList(), JobAds = GetMemberJobAdViews(member, results.Results.JobAdIds.SelectRange(range)), }, Folders = GetFoldersModel(), BlockLists = GetBlockListsModel(), }); }
private JobSearchModel GetSimilarJobSearchModel(IMember member, Guid jobAdId) { var execution = _executeJobAdSearchCommand.SearchSimilar(member, jobAdId, new Range(0, 1)); if (execution.Results.TotalMatches < 2) { return(null); } var jobAd = _jobAdsQuery.GetJobAd <JobAdEntry>(jobAdId); if (jobAd == null) { return(null); } return(new JobSearchModel { TotalMatches = execution.Results.TotalMatches, Description = jobAd.Title }); }
private IList <MemberJobAdView> GetSuggestedJobs(IMember member, JobAdView jobAd) { const string method = "GetSuggestedJobs"; try { // If the jobAd is closed and there is a query in the referrer then do a search. if (jobAd.Status == JobAdStatus.Closed) { var q = HttpContext.Request.UrlReferrer == null ? string.Empty : HttpUtility.ParseQueryString(HttpContext.Request.UrlReferrer.Query)["q"]; if (!string.IsNullOrEmpty(q)) { var criteria = new JobAdSearchCriteria(); criteria.SetKeywords(q); return(GetSuggestedJobs(member, _executeJobAdSearchCommand.Search(member, criteria, new Range(0, MaxSuggestedJobsCount)).Results)); } } // If the member is logged in then get suggested jobs. if (member != null) { return(GetSuggestedJobs(member, _executeJobAdSearchCommand.SearchSuggested(member, null, new Range(0, MaxSuggestedJobsCount)).Results)); } // Otherwise get similar jobs to this one. return(GetSuggestedJobs(null, _executeJobAdSearchCommand.SearchSimilar(null, jobAd.Id, new Range(0, MaxSuggestedJobsCount)).Results)); } catch (Exception ex) { // If there is a problem then log but don't stop the user doing what they need to do. EventSource.Raise(Event.Error, method, "Cannot get suggested jobs.", ex, new StandardErrorHandler(), Event.Arg("jobAdId", jobAd.Id)); return(new List <MemberJobAdView>()); } }