private void TestFlag(IEmployer employer, Guid memberId, bool expectedValue, Func <EmployerMemberView, bool> getFlag)
        {
            var view = _employerMemberViewsQuery.GetEmployerMemberView(employer, memberId);

            Assert.AreEqual(expectedValue, getFlag(view));

            view = _employerMemberViewsQuery.GetEmployerMemberViews(employer, new[] { memberId })[memberId];
            Assert.AreEqual(expectedValue, getFlag(view));
        }
Example #2
0
        public void TestCandidateEmailLinks()
        {
            var employer  = _employerAccountsCommand.CreateTestEmployer(0, _organisationsCommand.CreateTestOrganisation(0));
            var member    = _memberAccountsCommand.CreateTestMember(0);
            var candidate = _candidatesQuery.GetCandidate(member.Id);

            _candidateResumesCommand.AddTestResume(candidate);

            // Send an email.

            var view = _employerMemberViewsQuery.GetEmployerMemberView(employer, member);

            _emailsCommand.TrySend(new EmployerContactCandidateConfirmationEmail(null, employer, member.Id, view.GetDisplayText(true), "subject", "content"));

            // Check the email.

            var email = _emailServer.AssertEmailSent();
            var links = email.GetHtmlView().GetLinks();

            Assert.AreEqual(2, links.Count);

            var definition = typeof(EmployerContactCandidateConfirmationEmail).Name;

            AssertLink(definition, GetCandidateUrl(member), links[0]);
            AssertLink(definition, _contactUsUrl, links[1]);

            // Check the tracking pixel.

            var link = email.GetHtmlView().GetImageLinks().Last();

            AssertTrackingLink(link);

            // Check the MyCandidatesResumeEmail

            view = _employerMemberViewsQuery.GetEmployerMemberView(employer, member);
            _emailsCommand.TrySend(new CandidateResumeEmail(employer, view));

            // Check the email.

            email = _emailServer.AssertEmailSent();
            links = email.GetHtmlView().GetLinks();
            Assert.AreEqual(3, links.Count);

            definition = typeof(CandidateResumeEmail).Name;

            AssertLink(definition, GetCandidateUrl(member), links[0]);
            AssertLink(definition, _candidateSearchUrl, links[1]);
            AssertLink(definition, _contactUsUrl, links[2]);

            // Check the tracking pixel.

            link = email.GetHtmlView().GetImageLinks().Last();
            AssertTrackingLink(link);
        }
Example #3
0
        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);
        }
Example #4
0
        private ResumeFile GetResumeFile(IEmployer employer, Member member)
        {
            var candidate = _candidatesQuery.GetCandidate(member.Id);
            var resume    = candidate.ResumeId == null ? null : _resumesQuery.GetResume(candidate.ResumeId.Value);

            return(_resumeFilesQuery.GetResumeFile(_employerMemberViewsQuery.GetEmployerMemberView(employer, member), resume));
        }
Example #5
0
        private void AssertEmail(IEmployer employer, IList <Member> members, MockEmail email)
        {
            email.AssertSubject("Job candidates from LinkMe");
            email.AssertHtmlViewContains("4 suggested candidates");
            var view = _employerMemberViewsQuery.GetEmployerMemberView(employer, members[0]);

            email.AssertHtmlViewContains(view.GetDisplayText(false));
        }
Example #6
0
        public ActionResult PartialResume(Guid candidateId)
        {
            var employer = CurrentEmployer;
            var view     = _employerMemberViewsQuery.GetEmployerMemberView(employer, candidateId);

            var currentCandidate = GetCurrentCandidate(candidateId, view);

            // Mark them as viewed.

            _employerMemberViewsCommand.ViewMember(ActivityContext.Channel.App, employer, currentCandidate.View);

            return(PartialView("Resume", new ViewCandidatesModel
            {
                LastUpdatedTimes = GetLastUpdatedTimes(view),
                CurrentCandidate = currentCandidate,
                CurrentCandidates = EmployerContext.CurrentCandidates,
            }));
        }
Example #7
0
        private void SendEmailWithResume(InternalApplication application, Member member, JobAd jobAd)
        {
            var employer   = _employersQuery.GetEmployer(jobAd.PosterId);
            var view       = _employerMemberViewsQuery.GetEmployerMemberView(employer, member);
            var resume     = application.ResumeId == null ? new Resume() : _resumesQuery.GetResume(application.ResumeId.Value);
            var resumeFile = _resumeFilesQuery.GetResumeFile(view, resume);
            var stream     = new MemoryStream(Encoding.ASCII.GetBytes(resumeFile.Contents));

            // Send the email.

            _emailsCommand.TrySend(new JobApplicationEmail(member, application, jobAd, stream, resumeFile.FileName));
        }
Example #8
0
        private void TestCanAccessResume(IEmployer employer, bool hasContacted, CanContactStatus status)
        {
            // Has resume and is visible.

            var member = CreateMember(0, true, true);

            if (hasContacted)
            {
                CreateContact(employer.Id, member.Id);
            }
            Assert.AreEqual(status, _employerMemberViewsQuery.GetEmployerMemberView(employer, member).CanAccessResume());

            // No resume.

            member = CreateMember(1, true, false);
            if (hasContacted)
            {
                CreateContact(employer.Id, member.Id);
            }
            Assert.AreEqual(CanContactStatus.No, _employerMemberViewsQuery.GetEmployerMemberView(employer, member).CanAccessResume());

            // Resume not visible.

            member = CreateMember(2, false, true);
            if (hasContacted)
            {
                CreateContact(employer.Id, member.Id);
            }
            Assert.AreEqual(CanContactStatus.No, _employerMemberViewsQuery.GetEmployerMemberView(employer, member).CanAccessResume());

            // Resume not visible and no resume.

            member = CreateMember(4, false, false);
            if (hasContacted)
            {
                CreateContact(employer.Id, member.Id);
            }
            Assert.AreEqual(CanContactStatus.No, _employerMemberViewsQuery.GetEmployerMemberView(employer, member).CanAccessResume());
        }
Example #9
0
        public override TemplateEmail GeneratePreview(Community community)
        {
            if (community != null)
            {
                return(null);
            }

            // Create an employer.

            var employer = CreateEmployer();

            // Create a member.

            var member    = CreateMember();
            var candidate = _candidatesCommand.GetCandidate(member.Id);

            _candidateResumesCommand.AddTestResume(candidate);

            // Send the email.

            var view = _employerMemberViewsQuery.GetEmployerMemberView(employer, member);

            return(new CandidateResumeEmail(employer, view));
        }
        protected void AppendResults(StringBuilder sb, TemplateEmail templateEmail, IEmployer employer, MemberSearchResults results, int start, int count, bool useExtraReturn, ref int resultsWritten)
        {
            if (count > 0)
            {
                sb.AppendLine("  <div class=\"alert-container\">");
                sb.AppendLine();

                for (int index = start; index < start + count; index++)
                {
                    // Get the member for the result.

                    var view = _employerMemberViewsQuery.GetEmployerMemberView(employer, results.MemberIds[index]);
                    AppendResult(templateEmail, sb, view, index == start + 1 ? useExtraReturn : false, ref resultsWritten);
                }

                if (!useExtraReturn)
                {
                    sb.AppendLine();
                }
                sb.AppendLine("  </div>");
            }
        }
        public override TemplateEmail GeneratePreview(Community community)
        {
            if (community != null)
            {
                return(null);
            }

            // Create an employer.

            var employer = CreateEmployer();

            // Create a member.

            var member = CreateMember();

            // Send.

            var view = _employerMemberViewsQuery.GetEmployerMemberView(employer, member);

            return(new EmployerContactCandidateConfirmationEmail(null, employer, member.Id, view.GetDisplayText(true), Subject, Content));
        }
Example #12
0
        ResumeFile IResumeFilesQuery.GetResumeFile(RegisteredUser recipient, Member member, Candidate candidate, Resume resume)
        {
            if (candidate == null)
            {
                throw new ArgumentNullException("candidate");
            }
            if (recipient == null)
            {
                throw new ArgumentNullException("recipient");
            }

            EmployerMemberView view;
            var employer = recipient as Employer;

            if (employer != null)
            {
                view = _employerMemberViewsQuery.GetEmployerMemberView(employer, member);
            }
            else if (recipient is Member)
            {
                if (recipient.Id != member.Id)
                {
                    throw new ApplicationException("Downloading the resume of another member is not supported.");
                }
                view = new EmployerMemberView(member, candidate, resume, null, ProfessionalContactDegree.Self, false, false);
            }
            else if (recipient is Administrator)
            {
                view = new EmployerMemberView(member, candidate, resume, null, ProfessionalContactDegree.Self, false, false);
            }
            else
            {
                throw new ApplicationException("Unexpected type of recipient: " + recipient.GetType().FullName);
            }

            return(ConvertResume(view, resume));
        }
Example #13
0
 protected EmployerMemberView GetView(Employer employer, Member member)
 {
     return(_employerMemberViewsQuery.GetEmployerMemberView(employer, member.Id));
 }