コード例 #1
0
ファイル: GetContactsTests.cs プロジェクト: formist/LinkMe
        public void TestByEmailWithFirstDegreeContact()
        {
            var member    = _memberAccountsCommand.CreateTestMember(0);
            var activated = _memberAccountsCommand.CreateTestMember(EmailAddress1, FirstName, LastName1);

            activated.VisibilitySettings.Personal.Set(PersonalContactDegree.FirstDegree, PersonalVisibility.EmailAddress);
            activated.VisibilitySettings.Personal.Set(PersonalContactDegree.FirstDegree, PersonalVisibility.Name);
            _memberAccountsCommand.UpdateMember(activated);

            // Create contact.

            _networkingCommand.CreateFirstDegreeLink(activated.Id, member.Id);
            Assert.AreEqual(activated.Id, _memberContactsQuery.GetContact(member.Id, activated.GetBestEmailAddress().Address));
        }
コード例 #2
0
ファイル: FindFriends.aspx.cs プロジェクト: formist/LinkMe
        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;
        }