protected TListModel Search <TListModel>(IEmployer employer, CandidatesPresentationModel presentation, Func <IEmployer, Range, MemberSearchExecution> search) where TListModel : CandidateListModel, new() { presentation = PreparePresentationModel(presentation); // Search. var execution = search(employer, presentation.Pagination.ToRange()); var model = new TListModel { Criteria = execution.Criteria, Presentation = presentation, Results = new CandidateListResultsModel { TotalCandidates = execution.Results.TotalMatches, CandidateIds = execution.Results.MemberIds, CandidateStatusHits = GetEnumHitsDictionary(execution.Results.CandidateStatusHits, CandidateStatus.NotLooking), IndustryHits = execution.Results.IndustryHits, DesiredJobTypeHits = GetEnumHitsDictionary(execution.Results.DesiredJobTypeHits, JobTypes.All, JobTypes.None), }, }; // Only get details for those in the range. model.Results.Views = _employerMemberViewsQuery.GetEmployerMemberViews(employer, model.Results.CandidateIds); model.Results.LastUpdatedTimes = GetLastUpdatedTimes(model.Results.CandidateIds, model.Results.Views); return(model); }
public override TemplateEmail GeneratePreview(Community community) { if (community != null) { return(null); } // Create an employer. var employer = CreateEmployer(); // Create a member. var member1 = CreateMember(); var candidate = _candidatesCommand.GetCandidate(member1.Id); _candidateResumesCommand.AddTestResume(candidate); var member2 = CreateOtherMember(); candidate = _candidatesCommand.GetCandidate(member2.Id); _candidateResumesCommand.AddTestResume(candidate); // Send the email. var views = _employerMemberViewsQuery.GetEmployerMemberViews(employer, new [] { member1, member2 }); return(new CandidateResumesEmail(employer, views)); }
protected void AssertView(IEmployer employer, Member member, CanContactStatus canContact, bool phoneVisible, ProfessionalContactDegree contactDegree) { if (employer == null) { canContact = CanContactStatus.YesIfHadCredit; contactDegree = ProfessionalContactDegree.NotContacted; } var canContactByPhone = phoneVisible ? canContact : CanContactStatus.No; Assert.AreEqual(canContact, _employerMemberViewsQuery.CanContact(employer, member)); var view = _employerMemberViewsQuery.GetProfessionalView(employer, member.Id); Assert.AreEqual(canContact, view.CanContact()); Assert.AreEqual(canContactByPhone, view.CanContactByPhone()); Assert.AreEqual(contactDegree, view.EffectiveContactDegree); Assert.AreEqual(canContact, _employerMemberViewsQuery.GetProfessionalView(employer, member.Id).CanContact()); Assert.AreEqual(canContact, _employerMemberViewsQuery.GetProfessionalView(employer, member).CanContact()); Assert.AreEqual(canContact, _employerMemberViewsQuery.GetProfessionalViews(employer, new[] { member.Id })[member.Id].CanContact()); Assert.AreEqual(canContact, _employerMemberViewsQuery.GetEmployerMemberView(employer, member.Id).CanContact()); Assert.AreEqual(canContact, _employerMemberViewsQuery.GetEmployerMemberViews(employer, new[] { member.Id })[member.Id].CanContact()); Assert.AreEqual(contactDegree, _employerMemberViewsQuery.GetProfessionalView(employer, member.Id).EffectiveContactDegree); Assert.AreEqual(contactDegree, _employerMemberViewsQuery.GetProfessionalView(employer, member).EffectiveContactDegree); Assert.AreEqual(contactDegree, _employerMemberViewsQuery.GetProfessionalViews(employer, new[] { member.Id })[member.Id].EffectiveContactDegree); view = _employerMemberViewsQuery.GetProfessionalView(employer, member); Assert.AreEqual(canContact, view.CanContact()); Assert.AreEqual(canContactByPhone, view.CanContactByPhone()); Assert.AreEqual(contactDegree, view.EffectiveContactDegree); view = _employerMemberViewsQuery.GetProfessionalViews(employer, new[] { member.Id })[member.Id]; Assert.AreEqual(canContact, view.CanContact()); Assert.AreEqual(canContactByPhone, view.CanContactByPhone()); Assert.AreEqual(contactDegree, view.EffectiveContactDegree); view = _employerMemberViewsQuery.GetEmployerMemberView(employer, member.Id); Assert.AreEqual(canContact, view.CanContact()); Assert.AreEqual(canContactByPhone, view.CanContactByPhone()); Assert.AreEqual(contactDegree, view.EffectiveContactDegree); view = _employerMemberViewsQuery.GetEmployerMemberViews(employer, new[] { member.Id })[member.Id]; Assert.AreEqual(canContact, view.CanContact()); Assert.AreEqual(canContactByPhone, view.CanContactByPhone()); Assert.AreEqual(contactDegree, view.EffectiveContactDegree); }
public ActionResult Download(ResumeMimeType?mimeType, Guid[] candidateIds) { try { // Get the employer. var employer = CurrentEmployer; // Get the views to unlock the members. var professionalViews = _employerMemberViewsQuery.GetProfessionalViews(employer, candidateIds); _employerMemberViewsCommand.AccessMembers(ActivityContext.Channel.App, employer, professionalViews, MemberAccessReason.ResumeDownloaded); // Unlocking will change what the employer can see so get them again. var views = _employerMemberViewsQuery.GetEmployerMemberViews(employer, candidateIds); mimeType = GetMimeType(mimeType, candidateIds); switch (mimeType.Value) { case ResumeMimeType.Doc: return(DocFile(_employerResumeFilesQuery.GetResumeFile(views[candidateIds[0]]))); default: return(ZipFile(_employerResumeFilesQuery.GetResumeFile(views))); } } catch (UserException ex) { ModelState.AddModelError(ex, new StandardErrorHandler()); } return(View("Error")); }
protected CandidatesResponseModel Search(IEmployer employer, Func <IEmployer, MemberSearchExecution> search) { const string method = "API Search"; // Search. var execution = search(employer); if (EventSource.IsEnabled(Event.Trace)) { EventSource.Raise(Event.Trace, method, "Results retrieved.", Event.Arg("total hits", execution.Results.TotalMatches), Event.Arg("result count", execution.Results.MemberIds.Count)); } // Process results. var views = _employerMemberViewsQuery.GetEmployerMemberViews(employer, execution.Results.MemberIds); #region Log if (EventSource.IsEnabled(Event.Trace)) { EventSource.Raise(Event.Trace, method, "Results parsed.", Event.Arg("total results parsed", views.Count())); } #endregion return(new CandidatesResponseModel { TotalCandidates = execution.Results.TotalMatches, Candidates = (from id in execution.Results.MemberIds select GetCandidateModel(views[id])).ToList(), }); }
public override TemplateEmail GeneratePreview(Community community) { if (community != null) { return(null); } // Create an employer and search. var employer = CreateEmployer(0, true); var criteria = new MemberSearchCriteria { JobTitle = JobTitle, Location = _location, Salary = new Salary { LowerBound = 100000, UpperBound = 200000, Rate = SalaryRate.Year, Currency = Currency.AUD }, JobTypes = JobTypes.Contract, }; criteria.SetKeywords(SingleKeyword); var search = new MemberSearch { OwnerId = employer.Id, Criteria = criteria }; // Create some results. var results = CreateResults(1, false, false, false); // Send. return(new ResumeSearchAlertEmail(employer, criteria, null, results, _employerMemberViewsQuery.GetEmployerMemberViews(employer, results.MemberIds), search.Id)); }
public void TestMultipleMembersInFolders() { var employer0 = CreateEmployer(0); var employer1 = CreateEmployer(1, employer0.Organisation); var member0 = CreateMember(0); var member1 = CreateMember(1); var folder = new CandidateFolder { Name = FolderName }; _candidateFoldersCommand.CreateSharedFolder(employer0, folder); _candidateListsCommand.AddCandidateToFolder(employer0, folder, member0.Id); folder = _candidateFoldersQuery.GetShortlistFolder(employer0); _candidateListsCommand.AddCandidateToFolder(employer0, folder, member0.Id); _candidateListsCommand.AddCandidateToFolder(employer0, folder, member1.Id); TestCount(employer0, member0.Id, 2, v => v.Folders); TestCount(employer0, member1.Id, 1, v => v.Folders); TestCount(employer1, member0.Id, 1, v => v.Folders); TestCount(employer1, member1.Id, 0, v => v.Folders); var views = _employerMemberViewsQuery.GetEmployerMemberViews(employer0, new[] { member0.Id, member1.Id }); Assert.AreEqual(2, views[member0.Id].Folders); Assert.AreEqual(1, views[member1.Id].Folders); views = _employerMemberViewsQuery.GetEmployerMemberViews(employer1, new[] { member0.Id, member1.Id }); Assert.AreEqual(1, views[member0.Id].Folders); Assert.AreEqual(0, views[member1.Id].Folders); }
private bool SendEmail(string emailAddress, ICollection <SuggestedCandidatesResults> results) { const string method = "SendEmail"; if (results.Count == 0) { return(false); } // Find the registered employer for this address, if any. EventSource.Raise(Event.Trace, method, string.Format("Processing search results for '{0}'.", emailAddress)); var employer = GetEmployer(emailAddress); // Only include searches that returned results and only up to the maximum. Put new jobs first. var totalJobs = 0; var totalCandidates = 0; var suggestedCandidates = new List <SuggestedCandidates>(); foreach (var result in (from r in results where r.Execution.Results.TotalMatches > 0 orderby r.JobAd.CreatedTime descending select r).Take(MaxJobAdsPerEmail)) { // Save the search for reporting purposes. _memberSearchesCommand.CreateMemberSearchExecution(result.Execution); // Process the search results. totalJobs++; var jobCandidates = result.Execution.Results.MemberIds.Count; totalCandidates += jobCandidates; suggestedCandidates.Add(new SuggestedCandidates { JobAd = result.JobAd, TotalCandidates = result.Execution.Results.MemberIds.Count, CandidateIds = result.Execution.Results.MemberIds.Take(MaxResultsPerJobAd).ToList() }); } // Send the email if there are any results. if (totalCandidates == 0) { EventSource.Raise(Event.Trace, method, string.Format("No suggested candidates were found for any job ads for '{0}'.", emailAddress)); return(false); } var views = _employerMemberViewsQuery.GetEmployerMemberViews(employer, suggestedCandidates.SelectMany(e => e.CandidateIds).Distinct()); _emailsCommand.TrySend(new SuggestedCandidatesEmail(emailAddress, employer, totalCandidates, totalJobs, suggestedCandidates, views)); return(true); }
private ActionResult Resumes(Guid?currentCandidateId, IList <Guid> candidateIds) { // Get all views. var employer = CurrentEmployer; var views = _employerMemberViewsQuery.GetEmployerMemberViews(employer, candidateIds); // Filter candidates. candidateIds = GetFilteredCandidates(candidateIds, views); if (candidateIds.Count == 0) { return(NotFound("candidate")); } // Check url. if (candidateIds.Count == 1) { var result = EnsureUrl(views[candidateIds[0]].GenerateCandidateUrl()); if (result != null) { return(result); } } // Get the details for the current candidate. currentCandidateId = currentCandidateId == null && candidateIds.Count > 0 ? candidateIds[0] : currentCandidateId; var currentCandidate = GetCurrentCandidate(currentCandidateId, views[currentCandidateId]); // Mark the current candidate as viewed. if (currentCandidateId != null) { _employerMemberViewsCommand.ViewMember(ActivityContext.Channel.App, employer, views[currentCandidateId]); EmployerContext.Viewings = EmployerContext.Viewings + 1; } return(View("Resumes", new ViewCandidatesModel { CandidateIds = candidateIds, Views = views, LastUpdatedTimes = GetLastUpdatedTimes(candidateIds, views), CurrentCandidate = currentCandidate, CurrentCandidates = EmployerContext.CurrentCandidates, })); }
public ActionResult SendResumes(ResumeMimeType?mimeType, Guid[] candidateIds) { try { // Get the employer. var employer = CurrentEmployer; // Get the views to unlock the members. var professionalViews = _employerMemberViewsQuery.GetProfessionalViews(employer, candidateIds); _employerMemberViewsCommand.AccessMembers(ActivityContext.Channel.App, employer, professionalViews, MemberAccessReason.ResumeSent); // Get them again because unlocking will change what the employer can see. var views = _employerMemberViewsQuery.GetEmployerMemberViews(employer, candidateIds); EmployerEmail email; mimeType = GetMimeType(mimeType, candidateIds); switch (mimeType.Value) { case ResumeMimeType.Doc: email = new CandidateResumeEmail(employer, views[candidateIds[0]]); email.AddAttachments(new[] { GetResumeFile(views[candidateIds[0]]) }); break; default: email = new CandidateResumesEmail(employer, views); email.AddAttachments(new[] { GetResumeFile(views) }); break; } // Email it. _emailsCommand.TrySend(email); } catch (UserException ex) { ModelState.AddModelError(ex, new StandardErrorHandler()); } return(Json(new JsonResponseModel())); }
protected override void Alert(Employer employer, MemberSearch search, MemberSearchAlert alert, MemberSearchResults results) { var industries = search.Criteria.IndustryIds == null ? null : (from i in search.Criteria.IndustryIds select _industriesQuery.GetIndustry(i)).ToList(); _emailsCommand.TrySend(new ResumeSearchAlertEmail(employer, search.Criteria, industries, results, _employerMemberViewsQuery.GetEmployerMemberViews(employer, results.MemberIds), alert.MemberSearchId)); }
public override TemplateEmail GeneratePreview(Community community) { if (community != null) { return(null); } // Create a job ad. var employer = CreateEmployer(); var jobAds = PostJobAds(1, employer, MatchingJobTitle); // Create one candidate. var members = CreateMembers(1); // Send the email. return(new SuggestedCandidatesEmail(employer.EmailAddress.Address, employer, jobAds.Count * members.Count, jobAds.Count, GetSuggestedCandidates(jobAds, new[] { members }), _employerMemberViewsQuery.GetEmployerMemberViews(employer, members))); }
public void TestResumeSearchAlertEmail() { // Create an employer and search. var employer = _employerAccountsCommand.CreateTestEmployer(0, _organisationsCommand.CreateTestOrganisation(0)); var criteria = new MemberSearchCriteria { JobTitle = JobTitle }; var search = new MemberSearch { OwnerId = employer.Id, Criteria = criteria }; var member = _memberAccountsCommand.CreateTestMember(0); var candidate = _candidatesQuery.GetCandidate(member.Id); _candidateResumesCommand.AddTestResume(candidate); var results = new MemberSearchResults { MemberIds = new[] { member.Id }, TotalMatches = 1 }; // Send. _emailsCommand.TrySend(new ResumeSearchAlertEmail(employer, search.Criteria, null, results, _employerMemberViewsQuery.GetEmployerMemberViews(employer, results.MemberIds), search.Id)); // Check email. var email = _emailServer.AssertEmailSent(); var links = email.GetHtmlView().GetLinks(); Assert.AreEqual(3, links.Count); var definition = typeof(ResumeSearchAlertEmail).Name; // Check the tracking pixel. var link = email.GetHtmlView().GetImageLinks().Last(); AssertTrackingLink(link); // Not logged in. var url = _candidatesUrl.AsNonReadOnly(); url.QueryString.Add("candidateId", member.Id.ToString()); AssertLink(definition, employer, url, GetCandidateUrl(member), links[0]); AssertLink(definition, employer, _savedResumeSearchAlertsUrl, links[1]); AssertLink(definition, _contactUsUrl, links[2]); // Logged in. LogIn(employer); AssertLink(definition, GetCandidateUrl(member), links[0]); AssertLink(definition, _savedResumeSearchAlertsUrl, links[1]); }