private static ProfessionalContactDegree GetEffectiveContactDegree(ProfessionalContactDegree contactDegree, Allocation contactCreditsAllocation, bool hasBeenAccessed) { // If contacts are unlimited then access to everyone as long as the allocation has not expired. if (contactCreditsAllocation.RemainingQuantity == null) { if (!contactCreditsAllocation.HasExpired) { return(ProfessionalContactDegree.Contacted); } } else { // contactDegree reflects whether a contact credit has been used. For some old accesses though (before 22nd March 2010) // a credit usage may not have been recorded, e.g. for unlimited allocations. Therefore it is possible that an // employer has accessed a member but the contactDegree is still NotContacted. Adjust the effectiveContactDegree // by assuming that if a member has been accessed then there must have been a credit used somewhere, even if it // wasn't properly recorded. var effectiveContactDegree = contactDegree == ProfessionalContactDegree.Contacted || hasBeenAccessed ? ProfessionalContactDegree.Contacted : contactDegree; // Even if the member has been contacted they must still have credits. if (effectiveContactDegree == ProfessionalContactDegree.Contacted && !contactCreditsAllocation.HasExpired) { return(effectiveContactDegree); } } return(ProfessionalContactDegree.NotContacted); }
private ProfessionalVisibility GetVisibility(ProfessionalContactDegree degree, ProfessionalVisibilitySettings visibilitySettings) { // If the user is not enabled then no-one else should have any visibility of them unless they have // applied for a job. // If they are not activated but have already been contacted, or they have applied for a job // then treat them as normal. switch (degree) { case ProfessionalContactDegree.Self: return(ProfessionalVisibility.All); case ProfessionalContactDegree.Public: return(!_member.IsEnabled || !_member.IsActivated ? ProfessionalVisibilitySettings.None : visibilitySettings.PublicVisibility); case ProfessionalContactDegree.Contacted: return(!_member.IsEnabled ? ProfessionalVisibilitySettings.None : visibilitySettings.EmploymentVisibility | Contacted); case ProfessionalContactDegree.Applicant: return(visibilitySettings.EmploymentVisibility | Applicant); default: return(!_member.IsEnabled || !_member.IsActivated ? ProfessionalVisibilitySettings.None : visibilitySettings.EmploymentVisibility& NotContacted); } }
public ProfessionalView(Member member, int?contactCredits, ProfessionalContactDegree effectiveContactDegree, bool hasBeenAccessed, bool isRepresented) { _member = member; _contactCredits = contactCredits; _effectiveContactDegree = effectiveContactDegree; _hasBeenAccessed = hasBeenAccessed; _isRepresented = isRepresented; }
public ProfessionalView() { _contactCredits = 0; _member = new Member(); _effectiveContactDegree = ProfessionalContactDegree.NotContacted; _hasBeenAccessed = false; _isRepresented = false; }
private bool CanAccess(ProfessionalContactDegree contactDegree, ProfessionalVisibilitySettings visibilitySettings, ProfessionalVisibility visibility) { var contactVisibility = visibilitySettings == null ? GetPublicVisibility() : GetVisibility(contactDegree, visibilitySettings); return(contactVisibility.IsFlagSet(visibility)); }
private bool CanAccess(ProfessionalContactDegree contactDegree, ProfessionalVisibility visibility) { // Must always be able to view the resume as well as any other visibility. if (visibility == ProfessionalVisibility.Resume) { return(CanAccess(contactDegree, _member.VisibilitySettings.Professional, visibility)); } return(CanAccess(contactDegree, _member.VisibilitySettings.Professional, visibility) && CanAccess(contactDegree, _member.VisibilitySettings.Professional, ProfessionalVisibility.Resume)); }
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 EmployerMemberView(Member member, Candidate candidate, Resume resume, int?contactCredits, ProfessionalContactDegree effectiveContactDegree, bool hasBeenAccessed, bool isRepresented) : base(member, contactCredits, effectiveContactDegree, hasBeenAccessed, isRepresented) { _candidate = candidate; _resume = resume; }
public EmployerMemberView(Member member, int?contactCredits, ProfessionalContactDegree effectiveContactDegree, bool hasBeenAccessed, bool isRepresented) : base(member, contactCredits, effectiveContactDegree, hasBeenAccessed, isRepresented) { }
private void TestNoAccessMember(bool phoneVisible, bool allocateCredits, int?quantity, CanContactStatus canContact, ProfessionalContactDegree contactDegree) { var member = CreateMember(1, phoneVisible); var employer = CreateEmployer(allocateCredits, quantity, false, null); AssertView(employer, member, canContact, phoneVisible, contactDegree); }
private static ProfessionalContactDegree GetEffectiveContactDegree(IEmployer employer, IRegisteredUser member, ProfessionalContactDegree contactDegree, Allocation contactCreditsAllocation, bool hasBeenAccessed) { if (employer == null || member == null) { return(contactDegree); } if (contactDegree == ProfessionalContactDegree.Applicant) { return(contactDegree); } var affiliateId = employer.Organisation.AffiliateId; return(affiliateId == null ? GetEffectiveContactDegree(contactDegree, contactCreditsAllocation, hasBeenAccessed) : GetEffectiveContactDegree(affiliateId.Value, member)); }
protected ProfessionalView CreateView(Member member, ProfessionalContactDegree contactDegree, bool hasBeenAccessed) { return(CreateView(member, null, contactDegree, hasBeenAccessed, false)); }
public void CopyAccess(ProfessionalView other) { _contactCredits = other._contactCredits; _effectiveContactDegree = other._effectiveContactDegree; _isRepresented = other._isRepresented; }
protected virtual ProfessionalView CreateView(Member member, int?contactCredits, ProfessionalContactDegree contactDegree, bool hasBeenAccessed, bool isRepresented) { return(new ProfessionalView(member, contactCredits, contactDegree, hasBeenAccessed, isRepresented)); }
protected override ProfessionalView CreateView(Member member, int?contactCredits, ProfessionalContactDegree contactDegree, bool hasBeenAccessed, bool isRepresented) { return(new EmployerMemberView(member, contactCredits, contactDegree, hasBeenAccessed, isRepresented)); }
private static TView CreateView <TView>(Member member, Allocation contactCreditsAllocation, ProfessionalContactDegree degree, bool hasBeenAccessed, bool isRepresented) where TView : ProfessionalView { return((TView)(typeof(TView) == typeof(EmployerMemberView) ? new EmployerMemberView(member, contactCreditsAllocation.RemainingQuantity, degree, hasBeenAccessed, isRepresented) : new ProfessionalView(member, contactCreditsAllocation.RemainingQuantity, degree, hasBeenAccessed, isRepresented))); }
private static EmployerMemberView CreateView(Member member, Candidate candidate, Resume resume, ProfessionalContactDegree contactDegree, bool hasBeenAccessed) { return(new EmployerMemberView(member, candidate, resume, null, contactDegree, hasBeenAccessed, false)); }
protected ProfessionalView CreateView(bool isResumeOn, bool areOthersOn, ProfessionalContactDegree contactDegree, bool hasBeenAccessed) { return(CreateView(CreateMember(isResumeOn, areOthersOn), contactDegree, hasBeenAccessed)); }