Exemplo n.º 1
0
        /// <summary>
        /// Handle the event when user clicks AcceptRequest button
        /// Accept the friend request and add friend to friend list
        /// </summary>
        protected void btnAcceptRequest_Click(object sender, EventArgs e)
        {
            User user       = (User)Session["user"];
            User senderUser = UserADO.FindUserByUserName(((Button)sender).CommandArgument.ToString().Trim());

            FriendRequest friendRequest = user.FindReceivedRequest(senderUser.Id);

            if (FriendADO.WasFriend(user.Id, senderUser.Id))
            {
                if (FriendADO.UpdateFriendStatus(friendRequest.SenderID, friendRequest.ReceiverID))
                {
                    FriendRequestADO.AcceptRequest(friendRequest);
                }
                else
                {
                    string message = "Cannot accept the request!";
                    Session["message"] = message;
                }
            }
            else
            {
                if (FriendADO.InsertFriend(friendRequest.SenderID, friendRequest.ReceiverID))
                {
                    FriendRequestADO.AcceptRequest(friendRequest);
                }
                else
                {
                    string message = "Cannot accept the request!";
                    Session["message"] = message;
                }
            }

            BindRequests();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handle event when user clicks 'Accept Request' button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAcceptRequest_Click(object sender, EventArgs e)
        {
            User user       = (User)Session["user"];
            User senderUser = (User)Session["receiverUser"];

            FriendRequest friendRequest = user.FindReceivedRequest(senderUser.Id);

            if (FriendADO.WasFriend(user.Id, senderUser.Id))
            {
                if (FriendADO.UpdateFriendStatus(friendRequest.SenderID, friendRequest.ReceiverID))
                {
                    FriendRequestADO.AcceptRequest(friendRequest);
                    DisplayButtons();
                }
                else
                {
                    string message = "Cannot accept the request!";
                    Session["message"] = message;
                }
            }
            else
            {
                if (FriendADO.InsertFriend(friendRequest.SenderID, friendRequest.ReceiverID))
                {
                    FriendRequestADO.AcceptRequest(friendRequest);
                    DisplayButtons();
                }
                else
                {
                    string message = "Cannot accept the request!";
                    Session["message"] = message;
                }
            }
        }