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")); }
public void TestMultipleContactsMultipleAttachments() { var employer = CreateEmployer(0); _allocationsCommand.CreateAllocation(new Allocation { CreditId = _creditsQuery.GetCredit <ContactCredit>().Id, OwnerId = employer.Id }); const int count = 3; var members = new Member[count]; for (var index = 0; index < count; ++index) { members[index] = CreateMember(index); } // Save attachments. var attachments = new MemberMessageAttachment[count]; for (var index = 0; index < count; ++index) { attachments[index] = CreateMessageAttachment(employer, index); } // Check attachments. AssertAttachments(employer, attachments); // Create messages. var templateMessage = new ContactMemberMessage { Subject = Subject, Body = Body, AttachmentIds = (from a in attachments select a.Id).ToList() }; _employerMemberContactsCommand.ContactMembers(_app, employer, _employerMemberViewsQuery.GetProfessionalViews(employer, members), templateMessage); // Check. for (var index = 0; index < count; ++index) { var messages = _employerMemberContactsQuery.GetMessages(employer, members[index].Id); Assert.AreEqual(1, messages.Count); AssertMessage(templateMessage, messages[0], null, _employerContactsRepository.GetMemberMessageRepresentative(messages[0].Id)); } }
public void TestBulkDailyLimit() { var employer = CreateEmployer(); // Access up to the bulk daily limit doing 2 at a time. for (var index = 0; index < BulkDailyLimit / 2; ++index) { var member1 = CreateMember(2 * index); var member2 = CreateMember(2 * index + 1); // Check the counts. var counts = _repository.GetMemberAccessCounts(employer.Id, new[] { member1.Id, member2.Id }, new[] { GetAccessReason() }); Assert.AreEqual(2 * index, counts.Item1); Assert.AreEqual(2 * index, counts.Item2); _employerMemberViewsCommand.AccessMembers(_app, employer, _employerMemberViewsQuery.GetProfessionalViews(employer, new[] { member1, member2 }), GetAccessReason()); } // Go two more. try { var member1 = CreateMember(BulkDailyLimit); var member2 = CreateMember(BulkDailyLimit + 1); var counts = _repository.GetMemberAccessCounts(employer.Id, new[] { member1.Id, member2.Id }, new[] { GetAccessReason() }); Assert.AreEqual(BulkDailyLimit, counts.Item1); Assert.AreEqual(BulkDailyLimit, counts.Item2); _employerMemberViewsCommand.AccessMembers(_app, employer, _employerMemberViewsQuery.GetProfessionalViews(employer, new[] { member1, member2 }), GetAccessReason()); Assert.Fail(); } catch (TooManyAccessesException) { } }
public ActionResult PhoneNumbers(Guid[] candidateIds) { try { var employer = CurrentEmployer; var views = _employerMemberViewsQuery.GetProfessionalViews(employer, candidateIds); _employerMemberViewsCommand.AccessMembers(ActivityContext.Channel.App, employer, views, MemberAccessReason.PhoneNumberViewed); return(Json(new JsonResponseModel())); } catch (UserException ex) { ModelState.AddModelError(ex, new StandardErrorHandler()); } return(Json(new JsonResponseModel())); }