Beispiel #1
0
        void IMemberFriendsCommand.AcceptInvitation(Guid inviteeId, FriendInvitation invitation)
        {
            _networkingInvitationsCommand.AcceptInvitation(inviteeId, invitation);

            // Since the invitee is accepting the invitation make them friends.

            _networkingCommand.CreateFirstDegreeLink(invitation.InviterId, inviteeId);

            // Fire an event.

            var handlers = InvitationAccepted;

            if (handlers != null)
            {
                handlers(this, new EventArgs <Invitation>(invitation));
            }
        }
Beispiel #2
0
        public void TestInvitationCount()
        {
            var startDay = DateTime.Today;

            // Create users.

            var member1 = CreateMember(1, true);
            var member2 = CreateMember(2, true);
            var member3 = CreateMember(3, true);
            var member4 = CreateMember(4, true);

            // Send invitation.

            var invitation = new FriendInvitation {
                InviterId = member1.Id, InviteeId = member2.Id, Text = "invite", DonationRequestId = null
            };

            _networkingInvitationsCommand.CreateInvitation(invitation);
            _networkingInvitationsCommand.SendInvitation(invitation);

            _emailsCommand.TrySend(new StatsEmail(_dailyReportsQuery.GetDailyReport(DayRange.Today)));

            // Check. First email is invitation, second is stats.

            var email = _emailServer.AssertEmailSent();

            email.AssertHtmlViewContains("<td style=\"text-align:right;\">Invitations sent:</td>\r\n            <td style=\"text-align:left;\">1</td>");
            email.AssertHtmlViewContains("<td style=\"text-align:right;\">Invitations accepted:</td>\r\n            <td style=\"text-align:left;\">0</td>");

            // Accept the invitation.

            _networkingInvitationsCommand.AcceptInvitation(member2.Id, invitation);

            _emailsCommand.TrySend(new StatsEmail(_dailyReportsQuery.GetDailyReport(DayRange.Today)));

            email = _emailServer.AssertEmailSent();
            email.AssertHtmlViewContains("<td style=\"text-align:right;\">Invitations sent:</td>\r\n            <td style=\"text-align:left;\">1</td>");
            email.AssertHtmlViewContains("<td style=\"text-align:right;\">Invitations accepted:</td>\r\n            <td style=\"text-align:left;\">1</td>");

            // Send invitation to a non-member.

            invitation = new FriendInvitation {
                InviterId = member2.Id, InviteeEmailAddress = "*****@*****.**", Text = "invite", DonationRequestId = null
            };
            _networkingInvitationsCommand.CreateInvitation(invitation);
            _networkingInvitationsCommand.SendInvitation(invitation);

            _emailsCommand.TrySend(new StatsEmail(_dailyReportsQuery.GetDailyReport(DayRange.Today)));

            email = _emailServer.AssertEmailSent();
            email.AssertHtmlViewContains("<td style=\"text-align:right;\">Invitations sent:</td>\r\n            <td style=\"text-align:left;\">2</td>");
            email.AssertHtmlViewContains("<td style=\"text-align:right;\">Invitations accepted:</td>\r\n            <td style=\"text-align:left;\">1</td>");

            // Send and accept invitation but mark it as being sent outside the time period.

            invitation = new FriendInvitation {
                InviterId = member3.Id, InviteeId = member4.Id, Text = "invite", DonationRequestId = null
            };
            _networkingInvitationsCommand.CreateInvitation(invitation);
            _networkingInvitationsCommand.SendInvitation(invitation);

            invitation.FirstSentTime = startDay.AddDays(-7);
            invitation.LastSentTime  = startDay.AddDays(-7);
            _networkingInvitationsCommand.AcceptInvitation(member4.Id, invitation);

            _emailsCommand.TrySend(new StatsEmail(_dailyReportsQuery.GetDailyReport(DayRange.Today)));

            email = _emailServer.AssertEmailSent();
            email.AssertHtmlViewContains("<td style=\"text-align:right;\">Invitations sent:</td>\r\n            <td style=\"text-align:left;\">2</td>");
            email.AssertHtmlViewContains("<td style=\"text-align:right;\">Invitations accepted:</td>\r\n            <td style=\"text-align:left;\">2</td>");
        }
 private void AcceptInvitation(Guid inviteeId, NetworkingInvitation invitation, DateTime time)
 {
     _networkingInvitationsCommand.AcceptInvitation(inviteeId, invitation);
     invitation.ActionedTime = time;
     _networkingInvitationsCommand.UpdateInvitation(invitation);
 }