private void TestToMember(CommunityTestData fromData, bool isFromDeleted, CommunityTestData toData, bool isToDeleted, string expectedSnippet, string expectedHeaderSnippet) { var inviter = CreateInviter(fromData, isFromDeleted); // Invite member. var invitee = _memberAccountsCommand.CreateTestMember(1); if (toData != null) { var community = toData.CreateTestCommunity(_communitiesCommand, _verticalsCommand, _contentEngine); if (isToDeleted) { var vertical = _verticalsCommand.GetVertical(community); vertical.IsDeleted = true; _verticalsCommand.UpdateVertical(vertical); } _memberAffiliationsCommand.SetAffiliation(invitee.Id, community.Id); } var invitation = new FriendInvitation { InviterId = inviter.Id, InviteeId = invitee.Id }; _memberFriendsCommand.SendInvitation(invitation); // Check. var email = _emailServer.AssertEmailSent(); email.AssertAddresses(inviter, Return, invitee); AssertEmail(email, expectedSnippet, expectedHeaderSnippet); }
public void TestInvitationEmailLinks() { var category = _settingsQuery.GetCategory("MemberToMemberNotification"); // Create some members. var inviter = _memberAccountsCommand.CreateTestMember(EmailAddress); var invitee = _memberAccountsCommand.CreateTestMember(EmailAddress2); // Create an invitation. var invitation = new FriendInvitation { InviterId = inviter.Id, InviteeId = invitee.Id }; // Check settings. AssertSettings(invitee, category, Frequency.Immediately); _memberFriendsCommand.SendInvitation(invitation); var email = _emailServer.AssertEmailSent(); AssertUnsubscribeLink(invitee, category, email.GetHtmlView().GetLinks()[3]); // Accept the invitation. AssertSettings(inviter, category, Frequency.Immediately); _memberFriendsCommand.AcceptInvitation(invitee.Id, invitation); email = _emailServer.AssertEmailSent(); AssertUnsubscribeLink(invitee, category, email.GetHtmlView().GetLinks()[3]); }
private static IList <string> SendFriendInvitations(Guid inviterId, IEnumerable <string> inviteeEmailAddresses, string text, Guid?donationRequestId) { var firstDegreeContacts = new List <string>(); foreach (var emailAddress in inviteeEmailAddresses.Distinct()) { if (emailAddress != null && emailAddress.Trim().Length != 0) { // Check whether they are an existing member. var invitee = _membersQuery.GetMember(emailAddress); if (invitee != null) { // A member cannot invite themselves. if (invitee.Id != inviterId) { // Do not invite if they are already linked. if (_memberContactsQuery.AreFirstDegreeContacts(invitee.Id, inviterId)) { firstDegreeContacts.Add(emailAddress); } else { // Invitation for an already existing member (no donation request for existing members). _memberFriendsCommand.SendInvitation(new FriendInvitation { InviteeId = invitee.Id, InviterId = inviterId, Text = text }); } } } else { // Not a member so send them a new invitation. _memberFriendsCommand.SendInvitation(new FriendInvitation { DonationRequestId = donationRequestId, InviteeEmailAddress = emailAddress, InviterId = inviterId, Text = text }); } } } return(firstDegreeContacts.ToList()); }
private InformationMessage SendInvitation(Guid inviteeId) { const string method = "Send"; var invitation = new RepresentativeInvitation { InviterId = LoggedInMember.Id, InviteeId = inviteeId, Text = Request.Params[MessageParameter] }; try { _memberFriendsCommand.SendInvitation(invitation); return(GetInformationMessage("Your invitation was sent successfully.", false)); } catch (Exception ex) { EventSource.Raise(Event.Error, method, "Exception occurred while sending invitation", ex, new StandardErrorHandler()); return(GetInformationMessage("There was a problem sending your invitation.", true)); } }
public void TestFriendDailyLimit() { var member = _membersCommand.CreateTestMember(0); // Create 10 invitations. const int count = 10; for (var index = 1; index <= count; ++index) { var friend = _membersCommand.CreateTestMember(index); _memberFriendsCommand.SendInvitation(new FriendInvitation { InviterId = member.Id, InviteeId = friend.Id }); } // Try to send one more. var nextFriend = _membersCommand.CreateTestMember(count + 1); _memberFriendsCommand.SendInvitation(new FriendInvitation { InviterId = member.Id, InviteeId = nextFriend.Id }); }
public void TestReceivedFriendInvitations() { var member = _memberAccountsCommand.CreateTestMember(0); // Create invitations. var inviter1 = _memberAccountsCommand.CreateTestMember(1); var invitation1 = new FriendInvitation { InviterId = inviter1.Id, InviteeEmailAddress = member.GetBestEmailAddress().Address }; _memberFriendsCommand.SendInvitation(invitation1); var inviter2 = _memberAccountsCommand.CreateTestMember(2); var invitation2 = new FriendInvitation { InviterId = inviter2.Id, InviteeEmailAddress = member.GetBestEmailAddress().Address }; _memberFriendsCommand.SendInvitation(invitation2); var inviter3 = _memberAccountsCommand.CreateTestMember(3); var invitation3 = new FriendInvitation { InviterId = inviter3.Id, InviteeId = member.Id }; _memberFriendsCommand.SendInvitation(invitation3); // Assert all invites appear LogIn(member); GetPage <Invitations>(); AssertPageContains(inviter1.FullName); AssertPageContains(inviter2.FullName); AssertPageContains(inviter3.FullName); }
public void TestInvitationEmailLinks() { // Create some members. var inviter = _memberAccountsCommand.CreateTestMember(0); var invitee = _memberAccountsCommand.CreateTestMember(1); // Create an invitation. var invitation = new FriendInvitation { InviterId = inviter.Id, InviteeId = invitee.Id }; _memberFriendsCommand.SendInvitation(invitation); // Check the default variation. var email = _emailServer.AssertEmailSent(); var links = email.GetHtmlView().GetLinks(); Assert.AreEqual(4, links.Count); var definition = typeof(FriendInvitationEmail).Name; AssertLink(definition, invitee, _invitationsUrl, links[0]); AssertLink(definition, _contactUsUrl, links[1]); AssertLink(definition, invitee, _memberSettingsUrl, links[2]); AssertLink(definition, GetUnsubscribeUrl(invitee.Id.ToString("n"), "MemberToMemberNotification"), links[3]); // Check the tracking pixel. var link = email.GetHtmlView().GetImageLinks().Last(); AssertTrackingLink(link); // Accept the invitation. _memberFriendsCommand.AcceptInvitation(invitee.Id, invitation); // Check the email. email = _emailServer.AssertEmailSent(); links = email.GetHtmlView().GetLinks(); Assert.AreEqual(4, links.Count); definition = typeof(FriendInvitationConfirmationEmail).Name; // Not logged in. AssertLink(definition, _contactUsUrl, links[1]); AssertLink(definition, inviter, _memberSettingsUrl, links[2]); AssertLink(definition, GetUnsubscribeUrl(inviter.Id.ToString("n"), "MemberToMemberNotification"), links[3]); // Check the tracking pixel. link = email.GetHtmlView().GetImageLinks().Last(); AssertTrackingLink(link); // Invite non-member. invitation = new FriendInvitation { InviterId = inviter.Id, InviteeEmailAddress = EmailAddress }; _memberFriendsCommand.SendInvitation(invitation); // Check the email. email = _emailServer.AssertEmailSent(); links = email.GetHtmlView().GetLinks(); Assert.AreEqual(2, links.Count); definition = typeof(ContactInvitationEmail).Name; AssertLink(definition, new ReadOnlyApplicationUrl(true, "~/join", new ReadOnlyQueryString("inviteId", invitation.Id.ToString("n"))), links[0]); AssertLink(definition, _contactUsUrl, links[1]); // Check the tracking pixel. link = email.GetHtmlView().GetImageLinks().Last(); AssertTrackingLink(link); }