private void SetUpContactsList() { var friends = _memberContactsQuery.GetFirstDegreeContacts(LoggedInMember.Id); _friendsCount = friends.Count; if (_friendsCount == 0) { phNoFriendsText.Visible = true; phFriends.Visible = false; } var name = HtmlUtil.CleanScriptEventHtmlTags(Request.QueryString[NameParameter]); ucPagingBarTop.NameStartsWith = ucPagingBarBottom.NameStartsWith = name; var ids = string.IsNullOrEmpty(name) ? friends : _memberContactsQuery.GetFirstDegreeContacts(LoggedInMember.Id, name[0]); var members = _membersQuery.GetMembers(ids); var candidates = _candidatesQuery.GetCandidates(ids); var resumes = _resumesQuery.GetResumes(from c in candidates where c.ResumeId != null select c.ResumeId.Value); var views = _memberViewsQuery.GetPersonalViews(LoggedInMember.Id, members); contactsListControl.DisplayContacts(ids, views, members, candidates, resumes); if (contactsListControl.CountContacts < 1) { displayFriends.Visible = false; displayNoFriends.Visible = true; } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); // Choose a random set of friends to show, favouring those with photos. IList <Guid> friends = null; if (_friendsOwner != null) { friends = _memberContactsQuery.GetFirstDegreeContacts(_friendsOwner.Id, true).Randomise().Take(MaxFriendsToShow).ToList(); if (friends.Count < MaxFriendsToShow) { friends = friends.Concat(_memberContactsQuery.GetFirstDegreeContacts(_friendsOwner.Id, false).Randomise().Take(MaxFriendsToShow - friends.Count)).ToList(); } } if (friends != null && friends.Count > 0) { _views = _memberViewsQuery.GetPersonalViews(LoggedInMemberId, _membersQuery.GetMembers(friends)); rptMiniFriends.DataSource = friends; rptMiniFriends.DataBind(); } else { rptMiniFriends.Visible = false; } }
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); } } }
private void OnFriendInvitationSent(Member inviter, FriendInvitation invitation) { // Extra information. var view = new PersonalView(inviter, PersonalContactDegree.FirstDegree, PersonalContactDegree.Public); IList <Job> currentJobs = null; if (view.CanAccess(PersonalVisibility.CurrentJobs)) { var candidate = _candidatesQuery.GetCandidate(view.Id); var resume = candidate.ResumeId == null ? null : _resumesQuery.GetResume(candidate.ResumeId.Value); currentJobs = resume == null ? null : resume.CurrentJobs; } var contactCount = view.CanAccess(PersonalVisibility.FriendsList) ? _memberContactsQuery.GetFirstDegreeContacts(inviter.Id).Count : 0; if (invitation.InviteeId == null) { // Non-member. DonationRequest donationRequest = null; DonationRecipient donationRecipient = null; if (invitation.DonationRequestId != null) { donationRequest = _donationsQuery.GetRequest(invitation.DonationRequestId.Value); if (donationRequest != null) { donationRecipient = _donationsQuery.GetRecipient(donationRequest.RecipientId); } } var email = new ContactInvitationEmail(inviter, invitation, donationRequest, donationRecipient, currentJobs, contactCount); _emailsCommand.TrySend(email); } else { // Existing member. var to = _membersQuery.GetMember(invitation.InviteeId.Value); if (to != null) { var activation = GetEmailVerification(to, invitation); var email = new FriendInvitationEmail(to, inviter, invitation, activation, currentJobs, contactCount); _emailsCommand.TrySend(email); } } }
private string GetNameOfContactUserIdInNetwork(Guid memberId, string userId) { var contactIds = _memberContactsQuery.GetFirstDegreeContacts(memberId); var views = _memberViewsQuery.GetPersonalViews(memberId, contactIds); foreach (var contactId in contactIds) { if (views[contactId].GetBestEmailAddress().Address == userId) { return(views[contactId].FullName); } } return(""); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!IsPostBack) { if (LoggedInUserId != null) { var ids = _memberContactsQuery.GetFirstDegreeContacts(LoggedInUserId.Value, PersonalVisibility.SendMessages); var names = _membersQuery.GetFullNames(ids); //Initialise friends collection for Ajax drop down var sessWrapper = new HttpSessionWrapper(typeof(GetSuggestedContacts), Session); sessWrapper.SetValue(GetSuggestedContacts.SessionKey, names); } } }
public void TestAddFirstDegreeContacts() { var member1 = _memberAccountsCommand.CreateTestMember(1); Assert.IsTrue(_memberContactsQuery.GetFirstDegreeContacts(member1.Id).Count == 0); var member2 = _memberAccountsCommand.CreateTestMember(2); _networkingCommand.CreateFirstDegreeLink(member1.Id, member2.Id); AssertFirstDegreeContacts(member1.Id, member2.Id); }
public void TestExistingContact() { var invitee = _memberAccountsCommand.CreateTestMember(1); // LogIn. var member = LogIn(); _networkingCommand.CreateFirstDegreeLink(member.Id, invitee.Id); // Send. var contactIds = _memberContactsQuery.GetFirstDegreeContacts(member.Id); var views = _memberViewsQuery.GetPersonalViews(member.Id, contactIds); var emailAddress = views[contactIds[0]].EmailAddresses[0]; _txtEmailAddresses.Text = emailAddress.Address; _btnSendInvitations.Click(); AssertPage <InviteFriends>(); AssertPageContains("Already in your friends list:"); AssertPageContains(emailAddress.Address); }
public void TestNoFriends() { var member = _membersCommand.CreateTestMember(0); Assert.AreEqual(0, _memberContactsQuery.GetFirstDegreeContacts(member.Id).Count); }