public void TestFullName() { var member = CreateMember(false, true, true); var employer = CreateEmployer(); _employerMemberViewsCommand.AccessMember(_app, employer, _employerMemberViewsQuery.GetProfessionalView(employer, member), MemberAccessReason.PhoneNumberViewed); LogIn(employer); TestTitle(member.FullName); }
public void TestMessageAccess() { var employer0 = CreateEmployer(0); _allocationsCommand.CreateAllocation(new Allocation { CreditId = _creditsQuery.GetCredit <ContactCredit>().Id, OwnerId = employer0.Id }); var employer1 = CreateEmployer(1); _allocationsCommand.CreateAllocation(new Allocation { CreditId = _creditsQuery.GetCredit <ContactCredit>().Id, OwnerId = employer1.Id }); var member = CreateMember(0); // Create messages. var templateMessage = new ContactMemberMessage { Subject = Subject, Body = Body }; _employerMemberContactsCommand.ContactMember(_app, employer0, _employerMemberViewsQuery.GetProfessionalView(employer0, member), templateMessage); // Check. var messages = _employerMemberContactsQuery.GetMessages(employer0, member.Id); Assert.AreEqual(1, messages.Count); AssertMessage(templateMessage, messages[0], null, _employerContactsRepository.GetMemberMessageRepresentative(messages[0].Id)); messages = _employerMemberContactsQuery.GetMessages(employer1, member.Id); Assert.AreEqual(0, messages.Count); }
public ActionResult Photo(Guid candidateId) { // Get the employer. var employer = CurrentEmployer; // Get the view to the member. var view = _employerMemberViewsQuery.GetProfessionalView(employer, candidateId); if (view.PhotoId == null) { return(HttpNotFound()); } // Return the file. var fileReference = _filesQuery.GetFileReference(view.PhotoId.Value); if (fileReference == null) { return(HttpNotFound()); } return(File(_filesQuery.OpenFile(fileReference), fileReference.MediaType)); }
private void TestAction(CreditInfo creditInfo) { const int count = DailyLimit + 1; var members = new Member[count]; for (var index = 0; index < count; ++index) { members[index] = CreateMember(index); } var employer = creditInfo.CreateEmployer(members); _emailServer.ClearEmails(); if (employer != null) { LogIn(employer); } // Perform the action up to the limit. var reason = GetReason(); for (var index = 0; index < DailyLimit; ++index) { _employerMemberViewsCommand.AccessMember(_app, employer, _employerMemberViewsQuery.GetProfessionalView(employer, members[index]), reason); } // Perform the action to push it over the limit. PerformAction(employer, members[DailyLimit]); }
public void TestResumeSearchActivityXlsCredits() { var administrator = _administratorAccountsCommand.CreateTestAdministrator(1); var organisation = CreateVerifiedOrganisation(administrator.Id); var employer = _employerAccountsCommand.CreateTestEmployer(1, organisation); var member = _memberAccountsCommand.CreateTestMember(1); // Assign some credits. _allocationsCommand.CreateAllocation(new Allocation { CreatedTime = DateTime.Now.AddDays(-60), CreditId = _creditsQuery.GetCredit <ContactCredit>().Id, InitialQuantity = 100, OwnerId = organisation.Id, }); for (var index = 2; index < 20; ++index) { _employerMemberViewsCommand.AccessMember(_app, employer, _employerMemberViewsQuery.GetProfessionalView(employer, _memberAccountsCommand.CreateTestMember(index)), MemberAccessReason.PhoneNumberViewed); } _employerMemberViewsCommand.ViewMember(_app, employer, member); var report = _employerReportsCommand.CreateReportTemplate <ResumeSearchActivityReport>(organisation.Id); TestResults(administrator, organisation, report, ".xls", "application/vnd.ms-excel", _downloadButton); }
public void TestFilterIsUnlocked() { var member1 = CreateMember(1); var member2 = CreateMember(2); var employer = _employersCommand.CreateTestEmployer(1, _organisationsCommand.CreateTestOrganisation(1)); _allocationsCommand.CreateAllocation(new Allocation { CreditId = _creditsQuery.GetCredit <ContactCredit>().Id, InitialQuantity = 20, OwnerId = employer.Id }); // Member1 has been viewed. _employerMemberViewsCommand.AccessMember(_app, employer, _employerMemberViewsQuery.GetProfessionalView(employer, member1), MemberAccessReason.PhoneNumberViewed); // Filter. TestFilter(employer, CreateIsUnlockedCriteria, new[] { member1.Id, member2.Id }, new[] { member1.Id }, new[] { member2.Id }); }
private Member CreateMember(IEmployer employer, int index, bool isUnlocked) { var member = CreateMember(index); if (isUnlocked) { var view = _employerMemberViewsQuery.GetProfessionalView(employer, member); _employerMemberViewsCommand.AccessMember(_app, employer, view, MemberAccessReason.Unlock); } return(member); }
public override Employer CreateEmployer(Member[] members) { var employer = CreateEmployer(10, DateTime.Now.AddMonths(6).Date); foreach (var member in members) { _employerCreditsCommand.ExerciseContactCredit(employer, _employerMemberViewsQuery.GetProfessionalView(employer, member)); } if (HasExpired) { ExpireCredits(); } return(employer); }
private void TestCanContactByPhone(IEmployer employer, bool hasContacted, CanContactStatus status) { // Has phone number and is visible. var member = CreateMember(0, true, true, true); if (hasContacted) { CreateContact(employer.Id, member.Id); } Assert.AreEqual(status, _employerMemberViewsQuery.GetProfessionalView(employer, member).CanContactByPhone()); // No phone number. member = CreateMember(1, true, true, false); if (hasContacted) { CreateContact(employer.Id, member.Id); } Assert.AreEqual(CanContactStatus.No, _employerMemberViewsQuery.GetProfessionalView(employer, member).CanContactByPhone()); // Resume not visible. member = CreateMember(2, false, true, true); if (hasContacted) { CreateContact(employer.Id, member.Id); } Assert.AreEqual(CanContactStatus.No, _employerMemberViewsQuery.GetProfessionalView(employer, member).CanContactByPhone()); // Phone number not visible. member = CreateMember(3, true, false, true); if (hasContacted) { CreateContact(employer.Id, member.Id); } Assert.AreEqual(CanContactStatus.No, _employerMemberViewsQuery.GetProfessionalView(employer, member).CanContactByPhone()); // Resume not visible and no phone number. member = CreateMember(4, false, true, false); if (hasContacted) { CreateContact(employer.Id, member.Id); } Assert.AreEqual(CanContactStatus.No, _employerMemberViewsQuery.GetProfessionalView(employer, member).CanContactByPhone()); // Phone number not visible and no phone number. member = CreateMember(5, true, false, false); if (hasContacted) { CreateContact(employer.Id, member.Id); } Assert.AreEqual(CanContactStatus.No, _employerMemberViewsQuery.GetProfessionalView(employer, member).CanContactByPhone()); }
public void TestGetEmailMemberUnlockings() { var channel = _channelsQuery.GetChannel("Web"); var app = _channelsQuery.GetChannelApp(channel.Id, "Web"); Assert.AreEqual(0, _employerMemberAccessReportsQuery.GetEmployerMemberAccessReport(channel, DayRange.Today).MessagesSent); // Make some contacts. var employer1 = _employersCommand.CreateTestEmployer(1, _organisationsCommand.CreateTestOrganisation(1)); _allocationsCommand.CreateAllocation(new Allocation { CreditId = _creditsQuery.GetCredit <ContactCredit>().Id, OwnerId = employer1.Id }); var employer2 = _employersCommand.CreateTestEmployer(2, _organisationsCommand.CreateTestOrganisation(2)); _allocationsCommand.CreateAllocation(new Allocation { CreditId = _creditsQuery.GetCredit <ContactCredit>().Id, OwnerId = employer2.Id }); var member1 = _membersCommand.CreateTestMember(1); _userAccountsCommand.EnableUserAccount(member1, Guid.NewGuid()); member1 = _membersQuery.GetMember(member1.Id); var member2 = _membersCommand.CreateTestMember(2); _userAccountsCommand.EnableUserAccount(member2, Guid.NewGuid()); member2 = _membersQuery.GetMember(member2.Id); var member3 = _membersCommand.CreateTestMember(3); _userAccountsCommand.EnableUserAccount(member3, Guid.NewGuid()); member3 = _membersQuery.GetMember(member3.Id); _employerMemberViewsCommand.AccessMember(app, employer1, _employerMemberViewsQuery.GetProfessionalView(employer1, member1), MemberAccessReason.MessageSent); Assert.AreEqual(1, _employerMemberAccessReportsQuery.GetEmployerMemberAccessReport(channel, DayRange.Today).MessagesSent); _employerMemberViewsCommand.AccessMember(app, employer1, _employerMemberViewsQuery.GetProfessionalView(employer1, member2), MemberAccessReason.MessageSent); Assert.AreEqual(2, _employerMemberAccessReportsQuery.GetEmployerMemberAccessReport(channel, DayRange.Today).MessagesSent); _employerMemberViewsCommand.AccessMember(app, employer2, _employerMemberViewsQuery.GetProfessionalView(employer2, member1), MemberAccessReason.MessageSent); Assert.AreEqual(3, _employerMemberAccessReportsQuery.GetEmployerMemberAccessReport(channel, DayRange.Today).MessagesSent); _employerMemberViewsCommand.AccessMember(app, employer2, _employerMemberViewsQuery.GetProfessionalView(employer2, member3), MemberAccessReason.MessageSent); Assert.AreEqual(4, _employerMemberAccessReportsQuery.GetEmployerMemberAccessReport(channel, DayRange.Today).MessagesSent); }
public void TestLimitedContactedPhoto() { var member = CreateMember(); var employer = CreateEmployer(100); _employerMemberViewsCommand.AccessMember(_app, employer, _employerMemberViewsQuery.GetProfessionalView(employer, member), MemberAccessReason.Unlock); // Get the photo. LogIn(employer); Get(GetPhotoUrl(member.Id)); // Can see the photo because the member has been unlocked. Assert.AreEqual(HttpStatusCode.OK, Browser.CurrentStatusCode); Assert.AreEqual("image/jpeg", Browser.ResponseHeaders["Content-Type"]); }
private string GetContent(TemplateEmail templateEmail, Member member, ICandidate candidate, IEmployer employer) { var view = _employerMemberViewsQuery.GetProfessionalView(employer, member); var sb = new StringBuilder(); sb.AppendLine("<p>"); sb.AppendLine(" Please find attached the resume of"); sb.AppendLine(" <strong>" + (view.FullName ?? "[Name hidden]") + "</strong>"); sb.AppendLine(" as requested."); sb.AppendLine("</p>"); sb.AppendLine("<p>"); sb.AppendLine(" <a href=\"" + GetTinyUrl(templateEmail, true, "~/employers/candidates", "candidateId", candidate.Id.ToString()) + "\">View this resume</a>"); sb.AppendLine("</p>"); sb.AppendLine("<p>"); sb.AppendLine(" <a href=\"" + GetTinyUrl(templateEmail, true, "~/search/candidates") + "\">Search for more candidates</a>"); sb.AppendLine("</p>"); return(sb.ToString()); }
public void TestHasBeenAccessed() { var employer0 = CreateEmployer(0); _allocationsCommand.CreateAllocation(new Allocation { CreditId = _creditsQuery.GetCredit <ContactCredit>().Id, OwnerId = employer0.Id }); var employer1 = CreateEmployer(1, employer0.Organisation); var member = CreateMember(0); var view = _employerMemberViewsQuery.GetProfessionalView(employer0, member); _employerMemberViewsCommand.CheckCanAccessMember(_app, employer0, view, MemberAccessReason.MessageSent); _employerMemberViewsCommand.AccessMember(_app, employer0, view, MemberAccessReason.MessageSent); TestFlag(employer0, member.Id, true, v => v.HasBeenAccessed); TestFlag(employer1, member.Id, false, v => v.HasBeenAccessed); }
void IMessagesHandler.OnMessageSent(Guid fromId, Guid toId, Guid?representativeId, MemberMessage message) { var member = _membersQuery.GetMember(toId); var employer = _employersQuery.GetEmployer(fromId); IList <FileReference> fileReferences = null; if (message.AttachmentIds != null && message.AttachmentIds.Count > 0) { var messageAttachments = _employerMemberContactsQuery.GetMessageAttachments(employer, message.AttachmentIds); fileReferences = _filesQuery.GetFileReferences(from a in messageAttachments select a.FileReferenceId, new Range()); } // Create the email to send to the member and send it. TemplateEmail email; if (representativeId == null) { email = new ContactCandidateEmail(member, message.From, employer, message.Subject, GetMemberBody(message.Body, member)); } else { var representative = _membersQuery.GetMember(representativeId.Value); email = new RepresentativeContactCandidateEmail(representative, message.From, employer, member, message.Subject, GetMemberBody(message.Body, member)); } AddAttachments(email, fileReferences); _emailsCommand.TrySend(email); // Create the email to the employer and send it. if (message.SendCopy) { // Need the view. var view = _employerMemberViewsQuery.GetProfessionalView(employer, member); var confirmationEmail = new EmployerContactCandidateConfirmationEmail(message.From, employer, member.Id, view.GetFullNameDisplayText(), message.Subject, GetEmployerBody(message.Body, view)); AddAttachments(confirmationEmail, fileReferences); _emailsCommand.TrySend(confirmationEmail); } }
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); }
private void Contact(IEmployer employer, Member member) { var view = _employerMemberViewsQuery.GetProfessionalView(employer, member); _employerMemberViewsCommand.AccessMember(_app, employer, view, MemberAccessReason.Unlock); }
public void TestDailyLimit() { var employer = CreateEmployer(); // Access up to the daily limit. Member member; Tuple <int, int> counts; for (var index = 0; index < DailyLimit; ++index) { member = CreateMember(index); // Check the counts. counts = _repository.GetMemberAccessCounts(employer.Id, member.Id, new[] { GetAccessReason() }); Assert.AreEqual(index, counts.Item1); Assert.AreEqual(index, counts.Item2); _employerMemberViewsCommand.CheckCanAccessMember(_app, employer, _employerMemberViewsQuery.GetProfessionalView(employer, member), GetAccessReason()); _employerMemberViewsCommand.AccessMember(_app, employer, _employerMemberViewsQuery.GetProfessionalView(employer, member), GetAccessReason()); } // Go one more. member = CreateMember(DailyLimit); counts = _repository.GetMemberAccessCounts(employer.Id, member.Id, new[] { GetAccessReason() }); Assert.AreEqual(DailyLimit, counts.Item1); Assert.AreEqual(DailyLimit, counts.Item2); try { _employerMemberViewsCommand.CheckCanAccessMember(_app, employer, _employerMemberViewsQuery.GetProfessionalView(employer, member), GetAccessReason()); Assert.Fail(); } catch (TooManyAccessesException) { } try { _employerMemberViewsCommand.AccessMember(_app, employer, _employerMemberViewsQuery.GetProfessionalView(employer, member), GetAccessReason()); Assert.Fail(); } catch (TooManyAccessesException) { } }
public void TestEmployers() { var credit = _creditsQuery.GetCredit <ContactCredit>(); var unlimited = CreateEmployer(0); _allocationsCommand.CreateAllocation(new Allocation { CreditId = credit.Id, OwnerId = unlimited.Id, InitialQuantity = null }); var limited = CreateEmployer(1); _allocationsCommand.CreateAllocation(new Allocation { CreditId = credit.Id, OwnerId = limited.Id, InitialQuantity = 10 }); var none = CreateEmployer(2); _allocationsCommand.CreateAllocation(new Allocation { CreditId = credit.Id, OwnerId = none.Id, InitialQuantity = 1 }); var hasNotAccessed = _memberAccountsCommand.CreateTestMember(0); var candidate = _candidatesQuery.GetCandidate(hasNotAccessed.Id); _candidateResumesCommand.AddTestResume(candidate); var hasAccessed = _memberAccountsCommand.CreateTestMember(1); candidate = _candidatesQuery.GetCandidate(hasAccessed.Id); _candidateResumesCommand.AddTestResume(candidate); _employerMemberViewsCommand.AccessMember(_app, unlimited, _employerMemberViewsQuery.GetProfessionalView(unlimited, hasAccessed), MemberAccessReason.Unlock); _employerMemberViewsCommand.AccessMember(_app, limited, _employerMemberViewsQuery.GetProfessionalView(limited, hasAccessed), MemberAccessReason.Unlock); _employerMemberViewsCommand.AccessMember(_app, none, _employerMemberViewsQuery.GetProfessionalView(none, hasAccessed), MemberAccessReason.Unlock); }
protected void CheckCanAccessMember(IEmployer employer, Member member) { _employerMemberViewsCommand.CheckCanAccessMember(_app, employer, _employerMemberViewsQuery.GetProfessionalView(employer, member), MemberAccessReason.Unlock); }
protected void AccessMember(Employer employer, Member member) { var view = _employerMemberViewsQuery.GetProfessionalView(employer, member); _employerMemberViewsCommand.AccessMember(_app, employer, view, MemberAccessReason.Unlock); }