Esempio n. 1
0
        private void DisplayDetails()
        {
            // We want to display an error message if this person cannot view details.

            var canSeeName = _view.CanAccess(PersonalVisibility.Name);

            mainContactDetails.Visible = canSeeName;
            if (!canSeeName)
            {
                AddError(ValidationErrorMessages.ATTEMPTED_TO_VIEW_NETWORKER_WITHOUT_ACCESS_TO_NAME);
            }

            imgPhoto.ImageUrl = _view.GetPhotoUrlOrDefault().ToString();

            // Invitation.

            var invitation = _memberFriendsQuery.GetFriendInvitation(ViewedMember.Id, LoggedInMember.Id);

            phInvite.Visible = invitation == null &&
                               _view.CanAccess(PersonalVisibility.SendInvites) &&
                               _view.ActualContactDegree != PersonalContactDegree.Self && _view.ActualContactDegree != PersonalContactDegree.FirstDegree;

            phRemoveFriend.Visible = _view.ActualContactDegree == PersonalContactDegree.FirstDegree;
            phInvitation.Visible   = invitation != null && invitation.Status == RequestStatus.Pending;

            // Representative.

            phRepresentatives.Visible = false;
            switch (_view.EffectiveContactDegree)
            {
            case PersonalContactDegree.Representative:
            case PersonalContactDegree.Representee:
                phRepresentatives.Visible = true;
                break;
            }

            phAge.Visible = _view.CanAccess(PersonalVisibility.Age) &&
                            string.Compare(0.ToString(), GetAgeText()) != 0;
            phGender.Visible = _view.CanAccess(PersonalVisibility.Gender) &&
                               ViewedMember.Gender != Gender.Unspecified;
            phCountry.Visible = _view.CanAccess(PersonalVisibility.Country) &&
                                ViewedMember.Address.Location.CountrySubdivision.Country != null;

            var location = ViewedMember.Address.Location.ToString(_view.CanAccess(PersonalVisibility.CountrySubdivision), _view.CanAccess(PersonalVisibility.Suburb));

            if (string.IsNullOrEmpty(location))
            {
                phLocation.Visible = false;
            }
            else
            {
                phLocation.Visible = true;
                ltlLocation.Text   = HtmlUtil.TextToHtml(location);
            }
        }
Esempio n. 2
0
 private void AssertInvitations(Guid memberId, string body, DonationRequest request, params string[] emailAddresses)
 {
     foreach (var emailAddress in emailAddresses)
     {
         var invitation = _memberFriendsQuery.GetFriendInvitation(memberId, emailAddress);
         Assert.IsNotNull(invitation);
         Assert.AreEqual(body, invitation.Text);
         Assert.AreEqual(request == null ? (Guid?)null : request.Id, invitation.DonationRequestId);
     }
 }
        private void LoadControl()
        {
            const string method = "LoadControl";

            bool doSendInvitation = (Request.Params[SendInvitationParameter] == "true");

            Guid inviteeId = ParseUtil.ParseUserInputGuid(Request.Params[InviteeIdParameter], "invitee ID");

            if (inviteeId == LoggedInMember.Id)
            {
                Controls.Add(GetInformationMessage(CannotAddSelfToFriends, 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.ActualContactDegree == PersonalContactDegree.FirstDegree)
            {
                Controls.Add(GetInformationMessage(string.Format(AlreadyFriendsFormat, invitee.FullName), false));
                return;
            }

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

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

            if (view.CanAccess(PersonalVisibility.SendInvites))
            {
                if (doSendInvitation)
                {
                    Controls.Add(Send(invitee.Id));
                }
                else
                {
                    Controls.Add(GetAddToFriends(invitee));
                }
            }
            else
            {
                Controls.Add(GetInformationMessage(NotAcceptingInvitations, false));
            }
        }
Esempio n. 4
0
        protected void rptInvitations_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            var invitationId = new Guid((string)e.CommandArgument);
            var invitation   = _memberFriendsQuery.GetFriendInvitation(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
        }
Esempio n. 5
0
 private FriendInvitation GetFriendInvitation(Guid?friendInvitationId)
 {
     return(friendInvitationId == null ? null : _memberFriendsQuery.GetFriendInvitation(friendInvitationId.Value));
 }