Beispiel #1
0
    /// <summary>
    /// Approves the friendship. Called when the "Approve friendship" button is pressed.
    /// Expects the RequestFriendship method to be run first.
    /// </summary>
    private bool ApproveFriendship()
    {
        // Get the users involved in the friendship
        UserInfo user   = MembershipContext.AuthenticatedUser;
        UserInfo friend = UserInfoProvider.GetUserInfo("MyNewFriend");

        if (friend != null)
        {
            // Get the friendship with current user
            FriendInfo updateFriendship = FriendInfoProvider.GetFriendInfo(user.UserID, friend.UserID);
            if (updateFriendship != null)
            {
                // Set its properties
                updateFriendship.FriendStatus       = FriendshipStatusEnum.Approved;
                updateFriendship.FriendRejectedBy   = 0;
                updateFriendship.FriendApprovedBy   = user.UserID;
                updateFriendship.FriendApprovedWhen = DateTime.Now;

                // Save the changes to database
                FriendInfoProvider.SetFriendInfo(updateFriendship);

                return(true);
            }
        }

        return(false);
    }
Beispiel #2
0
    /// <summary>
    /// Gets and bulk updates friends. Called when the "Get and bulk update friends" button is pressed.
    /// Expects the RequestFriendship method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateFriends()
    {
        // Get the user
        UserInfo friend = UserInfoProvider.GetUserInfo("MyNewFriend");

        if (friend != null)
        {
            // Prepare the parameters
            string where = "FriendRequestedUserID = " + friend.UserID;

            // Get the data
            DataSet friends = FriendInfoProvider.GetFriends(where, null);
            if (!DataHelper.DataSourceIsEmpty(friends))
            {
                // Loop through the individual items
                foreach (DataRow friendDr in friends.Tables[0].Rows)
                {
                    // Create object from DataRow
                    FriendInfo modifyFriend = new FriendInfo(friendDr);

                    // Update the properties
                    modifyFriend.FriendStatus       = FriendshipStatusEnum.Approved;
                    modifyFriend.FriendRejectedBy   = 0;
                    modifyFriend.FriendApprovedBy   = MembershipContext.AuthenticatedUser.UserID;
                    modifyFriend.FriendApprovedWhen = DateTime.Now;

                    // Save the changes
                    FriendInfoProvider.SetFriendInfo(modifyFriend);
                }

                return(true);
            }
        }
        return(false);
    }
Beispiel #3
0
    /// <summary>
    /// Creates friend. Called when the "Create friend" button is pressed.
    /// </summary>
    private bool RequestFriendship()
    {
        // First create a new user which the friendship request will be sent to
        UserInfo newFriend = new UserInfo();

        newFriend.UserName = "******";
        newFriend.FullName = "My new friend";
        newFriend.UserGUID = Guid.NewGuid();

        UserInfoProvider.SetUserInfo(newFriend);

        // Create new friend object
        FriendInfo newFriendship = new FriendInfo();

        // Set the properties
        newFriendship.FriendUserID          = MembershipContext.AuthenticatedUser.UserID;
        newFriendship.FriendRequestedUserID = newFriend.UserID;
        newFriendship.FriendRequestedWhen   = DateTime.Now;
        newFriendship.FriendComment         = "Sample friend request comment.";
        newFriendship.FriendStatus          = FriendshipStatusEnum.Waiting;
        newFriendship.FriendGUID            = Guid.NewGuid();

        // Save the friend
        FriendInfoProvider.SetFriendInfo(newFriendship);

        return(true);
    }
Beispiel #4
0
    protected void btnApprove_Click(object sender, EventArgs e)
    {
        lblInfo.Text                  = ApprovedCaption;
        friendship.FriendStatus       = FriendshipStatusEnum.Approved;
        friendship.FriendApprovedBy   = friendship.FriendRequestedUserID;
        friendship.FriendApprovedWhen = DateTime.Now;
        FriendInfoProvider.SetFriendInfo(friendship);

        plcConfirm.Visible = false;
        plcMessage.Visible = true;

        action = FriendsActionEnum.Approve;

        // Send notification
        SentNotification();
    }