Example #1
0
        private void LoadControl()
        {
            const string method = "LoadControl";

            var doSendInvitation = (Request.Params[SendInvitationParameter] == "true");
            var inviteeId        = ParseUtil.ParseUserInputGuid(Request.Params[InviteeIdParameter], "invitee ID");

            if (inviteeId == LoggedInMember.Id)
            {
                Controls.Add(GetInformationMessage(CannotYourselfBeRepresentative, true));
                return;
            }

            var invitee = _membersQuery.GetMember(inviteeId);

            if (invitee == null)
            {
                Controls.Add(GetInformationMessage(CouldNotFindMember, true));
                EventSource.Raise(Event.Error, method, string.Format("Tried to invite nonexistent member. inviteeId: {0}", inviteeId));
                return;
            }

            var view = _memberViewsQuery.GetPersonalView(LoggedInMember.Id, invitee);

            if (view.EffectiveContactDegree == PersonalContactDegree.Representative)
            {
                Controls.Add(GetInformationMessage(string.Format(AlreadyRepresentativeFormat, invitee.FullName), false));
                return;
            }

            var invitation = _memberFriendsQuery.GetRepresentativeInvitation(LoggedInMember.Id, invitee.Id);

            if (invitation != null && !_memberFriendsCommand.CanSendInvitation(invitation))
            {
                Controls.Add(GetInformationMessage(GetSendingNotAllowedReason(invitee, invitation), false));
                return;
            }

            if (!view.CanAccess(PersonalVisibility.SendInvites))
            {
                Controls.Add(GetInformationMessage(NotAcceptingInvitations, false));
                return;
            }

            if (doSendInvitation)
            {
                Controls.Add(SendInvitation(invitee.Id));
            }
            else
            {
                Controls.Add(GetInviteRepresentative(invitee));
            }
        }
Example #2
0
        protected void rptRepresentativeInvitations_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            var invitationId = new Guid((string)e.CommandArgument);
            var invitation   = _memberFriendsQuery.GetRepresentativeInvitation(invitationId);

            if (invitation == null)
            {
                LinkMePage.AddError(ValidationErrorMessages.INVALID_INVITATION);
                return;
            }

            var inviter = _membersQuery.GetMember(invitation.InviterId);

            switch (e.CommandName)
            {
            case "AcceptInvitation":
                try
                {
                    _memberFriendsCommand.AcceptInvitation(LoggedInMember.Id, invitation);
                    var successMsg = invitation.GetInvitationAcceptedHtml(inviter);
                    LinkMePage.AddConfirm(successMsg, false);
                }
                catch (UserException ex)
                {
                    LinkMePage.AddError(ex);
                }
                break;

            case "IgnoreInvitation":
                _memberFriendsCommand.RejectInvitation(invitation);
                LinkMePage.AddConfirm(string.Format(ValidationInfoMessages.INVITE_IGNORED, inviter.FullName.MakeNamePossessive()));
                break;
            }

            InitialiseInvitations(); // Re-initialise - just hiding items casuses bug 8772
        }
Example #3
0
 protected void AssertInvitation(Guid inviterId, Guid inviteeId, string message)
 {
     AssertInvitation(inviterId, inviteeId, message, _memberFriendsQuery.GetRepresentativeInvitation(inviterId, inviteeId));
     AssertInvitation(inviterId, inviteeId, message, _memberFriendsQuery.GetRepresentativeInvitationByInviter(inviterId));
 }