示例#1
0
        private void TestByName(Guid memberId, Guid activatedId, Guid deactivatedId)
        {
            var ids = _memberContactsQuery.GetContacts(memberId, FirstName, false);

            Assert.IsTrue(ids.Contains(activatedId));
            Assert.IsFalse(ids.Contains(deactivatedId));
        }
示例#2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            ucPagingBarTop.ResultsPerPage  = ucPagingBarBottom.ResultsPerPage = ApplicationContext.Instance.GetIntProperty(ApplicationContext.FRIENDS_PER_PAGE);
            ucPagingBarTop.StartIndexParam = ucPagingBarBottom.StartIndexParam = ResultParameter;

            if (!Page.IsPostBack)
            {
                try
                {
                    // Get the owner of the contacts being viewed.

                    var memberId = ParseUtil.ParseUserInputGuid(Request.QueryString[SearchHelper.MemberIdParam], "member ID");
                    OwnerOfFriends = _membersQuery.GetMember(memberId);
                    if (OwnerOfFriends == null)
                    {
                        throw new UserException("There is no networker with the specified ID.");
                    }

                    IList <Guid> friendIds = _memberContactsQuery.GetFirstDegreeContacts(OwnerOfFriends.Id);
                    _ownersFriendCount = friendIds.Count;

                    // Get the list of friends to display on this page that the viewer can actually see.

                    friendIds = _memberContactsQuery.GetContacts(LoggedInUserId.Value, friendIds);
                    friendIds = friendIds.Skip(ucPagingBarTop.StartIndex).Take(ucPagingBarTop.ResultsPerPage).ToList();

                    // Get the members and networker.

                    var members    = _membersQuery.GetMembers(friendIds);
                    var candidates = _candidatesQuery.GetCandidates(friendIds);
                    var resumes    = _resumesQuery.GetResumes(from c in candidates where c.ResumeId != null select c.ResumeId.Value);
                    var views      = _memberViewsQuery.GetPersonalViews(LoggedInUserId, members);

                    // Get the contact degree for the owner.

                    var view = _memberViewsQuery.GetPersonalView(LoggedInUserId.Value, OwnerOfFriends);
                    SetPageVisibility(view.EffectiveContactDegree, view.ActualContactDegree);

                    ucPagingBarTop.InitPagesList(GetResultUrl(), _ownersFriendCount, false);
                    ucPagingBarBottom.InitPagesList(GetResultUrl(), _ownersFriendCount, false);
                    contactsListControl.DisplayContacts(friendIds, views, members, candidates, resumes);
                }
                catch (UserException ex)
                {
                    AddError(ex.Message);
                }
            }
        }
示例#3
0
        private void OnSearchRequested(NameValueCollection query)
        {
            var name         = query[NameQueryParameter];
            var emailAddress = query[EmailQueryParameter];

            txtQuery.Text = name;
            txtEmail.Text = emailAddress;

            if (!string.IsNullOrEmpty(name) || !string.IsNullOrEmpty(emailAddress))
            {
                if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(emailAddress))
                {
                    AddError("Please enter a name or email address, not both");
                    return;
                }

                if (!string.IsNullOrEmpty(name))
                {
                    if (new Regex(LinkMe.Domain.RegularExpressions.DisallowedNameCharPattern).IsMatch(name))
                    {
                        AddError(ValidationErrorMessages.INVALID_NAME_SEARCH_CRITERIA + " " + ValidationErrorMessages.PLEASE_TRY_AGAIN);
                        return;
                    }
                }

                if (!string.IsNullOrEmpty(emailAddress))
                {
                    IValidator validator = EmailAddressValidatorFactory.CreateValidator(EmailAddressValidationMode.SingleEmail, false);
                    var        errors    = validator.IsValid(emailAddress)
                        ? null
                        : validator.GetValidationErrors("EmailAddress");

                    if (errors != null && errors.Length > 0)
                    {
                        AddError(((IErrorHandler) new StandardErrorHandler()).FormatErrorMessage(errors[0]) + " " + ValidationErrorMessages.PLEASE_TRY_AGAIN);
                        return;
                    }
                }
            }
            else
            {
                AddError(string.Format(ValidationErrorMessages.REQUIRED_FIELD_MISSING_1, "search term"));
                return;
            }


            var loggedInNetworkerId = LoggedInUserId.Value;
            var exactMatch          = ParseUtil.ParseUserInputBooleanOptional(Request.QueryString[ExactMatchParameter], "exactMatch parameter", false);

            // Perform find by email address search.

            IList <Guid> resultIds;

            if (!string.IsNullOrEmpty(emailAddress))
            {
                var id = _memberContactsQuery.GetContact(loggedInNetworkerId, emailAddress);
                resultIds = id == null ? new Guid[0] : new[] { id.Value };
            }
            else
            {
                resultIds = _memberContactsQuery.GetContacts(loggedInNetworkerId, name, exactMatch);
            }

            InitPagingBar(resultIds.Count, name);
            var results = ucPagingBar.GetResultSubset(resultIds);

            var haveResults = (results.Count > 0);

            if (haveResults)
            {
                var members    = _membersQuery.GetMembers(results);
                var candidates = _candidatesQuery.GetCandidates(results);
                var resumes    = _resumesQuery.GetResumes(from c in candidates where c.ResumeId != null select c.ResumeId.Value);
                var views      = _memberViewsQuery.GetPersonalViews(LoggedInUserId, members);
                ucResultList.DisplayContacts(results, views, members, candidates, resumes);
            }

            ucResultList.Visible = haveResults;
            phNoMatches.Visible  = !haveResults;
            phResults.Visible    = true;
        }