コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: ProfessionalView.cs プロジェクト: formist/LinkMe
        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);
            }
        }
コード例 #3
0
ファイル: ProfessionalView.cs プロジェクト: formist/LinkMe
 public ProfessionalView(Member member, int?contactCredits, ProfessionalContactDegree effectiveContactDegree, bool hasBeenAccessed, bool isRepresented)
 {
     _member                 = member;
     _contactCredits         = contactCredits;
     _effectiveContactDegree = effectiveContactDegree;
     _hasBeenAccessed        = hasBeenAccessed;
     _isRepresented          = isRepresented;
 }
コード例 #4
0
ファイル: ProfessionalView.cs プロジェクト: formist/LinkMe
 public ProfessionalView()
 {
     _contactCredits         = 0;
     _member                 = new Member();
     _effectiveContactDegree = ProfessionalContactDegree.NotContacted;
     _hasBeenAccessed        = false;
     _isRepresented          = false;
 }
コード例 #5
0
ファイル: ProfessionalView.cs プロジェクト: formist/LinkMe
        private bool CanAccess(ProfessionalContactDegree contactDegree, ProfessionalVisibilitySettings visibilitySettings, ProfessionalVisibility visibility)
        {
            var contactVisibility = visibilitySettings == null
                ? GetPublicVisibility()
                : GetVisibility(contactDegree, visibilitySettings);

            return(contactVisibility.IsFlagSet(visibility));
        }
コード例 #6
0
ファイル: ProfessionalView.cs プロジェクト: formist/LinkMe
        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));
        }
コード例 #7
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);
        }
コード例 #8
0
 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;
 }
コード例 #9
0
 public EmployerMemberView(Member member, int?contactCredits, ProfessionalContactDegree effectiveContactDegree, bool hasBeenAccessed, bool isRepresented)
     : base(member, contactCredits, effectiveContactDegree, hasBeenAccessed, isRepresented)
 {
 }
コード例 #10
0
ファイル: ContactTests.cs プロジェクト: formist/LinkMe
        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);
        }
コード例 #11
0
        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));
        }
コード例 #12
0
 protected ProfessionalView CreateView(Member member, ProfessionalContactDegree contactDegree, bool hasBeenAccessed)
 {
     return(CreateView(member, null, contactDegree, hasBeenAccessed, false));
 }
コード例 #13
0
ファイル: ProfessionalView.cs プロジェクト: formist/LinkMe
 public void CopyAccess(ProfessionalView other)
 {
     _contactCredits         = other._contactCredits;
     _effectiveContactDegree = other._effectiveContactDegree;
     _isRepresented          = other._isRepresented;
 }
コード例 #14
0
 protected virtual ProfessionalView CreateView(Member member, int?contactCredits, ProfessionalContactDegree contactDegree, bool hasBeenAccessed, bool isRepresented)
 {
     return(new ProfessionalView(member, contactCredits, contactDegree, hasBeenAccessed, isRepresented));
 }
コード例 #15
0
 protected override ProfessionalView CreateView(Member member, int?contactCredits, ProfessionalContactDegree contactDegree, bool hasBeenAccessed, bool isRepresented)
 {
     return(new EmployerMemberView(member, contactCredits, contactDegree, hasBeenAccessed, isRepresented));
 }
コード例 #16
0
 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)));
 }
コード例 #17
0
 private static EmployerMemberView CreateView(Member member, Candidate candidate, Resume resume, ProfessionalContactDegree contactDegree, bool hasBeenAccessed)
 {
     return(new EmployerMemberView(member, candidate, resume, null, contactDegree, hasBeenAccessed, false));
 }
コード例 #18
0
 protected ProfessionalView CreateView(bool isResumeOn, bool areOthersOn, ProfessionalContactDegree contactDegree, bool hasBeenAccessed)
 {
     return(CreateView(CreateMember(isResumeOn, areOthersOn), contactDegree, hasBeenAccessed));
 }