Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Cs_CommonFunction.IsUserLoggedIn())
            {
                Response.Redirect("~/Default.aspx");
            }
            if (!IsPostBack)
            {
                if (string.IsNullOrEmpty(Request.QueryString["UserID"]))
                {
                    RequestUserID = Session["UserID"].ToString();
                }
                else
                {
                    RequestUserID = Request.QueryString["UserID"];
                }
                string CurrentUserID = Session["UserID"].ToString();

                if (RequestUserID == CurrentUserID)
                {
                    pnlSendFriendRequest.Visible = false;
                    lnkEditProfile.Visible       = true;
                }
                else
                {
                    Cs_Friend cs_Friend = new Cs_Friend();
                    DataTable dt        = cs_Friend.IsFriendRequestSent(CurrentUserID, RequestUserID);
                    if (Convert.ToString(dt.Rows[0][0]) == "NotFriend" || Convert.ToString(dt.Rows[0][0]) == "FriendRequestRejected")
                    {
                        if (Request.QueryString["Request"] == "0")
                        {
                            lnkSendRequest.Visible = false;
                            ddlPrivacy.Visible     = false;
                        }
                        else
                        {
                            lnkSendRequest.OnClientClick = "return sendFriendRequest(" + RequestUserID + ",this)";
                        }
                    }
                    else if (Convert.ToString(dt.Rows[0][0]) == "FriendRequestSent")
                    {
                        pnlSendFriendRequest.Visible = false;
                        lblStatus.Text = "Waiting for approval";
                    }
                    else if (Convert.ToString(dt.Rows[0][0]) == "")
                    {
                        if (Request.QueryString["Request"] == "0")
                        {
                            pnlSendFriendRequest.Visible = false;
                        }
                        lnkSendRequest.OnClientClick = "return sendFriendRequest(" + RequestUserID + ",this)";
                    }
                    else
                    {
                        pnlSendFriendRequest.Visible = false;
                    }
                }
            }
        }
Esempio n. 2
0
        public void ApproveRejectRequest(string notificationID, string action)
        {
            if (!Cs_CommonFunction.IsUserLoggedIn())
            {
                return;
            }
            Cs_Friend cs_Friend     = new Cs_Friend();
            int       CurrentUserID = (int)Session["UserID"];

            cs_Friend.ApproveRejectRequest(notificationID, action);
        }
Esempio n. 3
0
        public void SendFriendRequest(string userID, int privacy)
        {
            if (!Cs_CommonFunction.IsUserLoggedIn())
            {
                return;
            }
            Cs_Friend cs_Friend     = new Cs_Friend();
            int       CurrentUserID = (int)Session["UserID"];

            cs_Friend.SendFriendRequest(userID, CurrentUserID, privacy);
        }
Esempio n. 4
0
        public List <Cs_OnlineUser> GetOnlineUsers()
        {
            if (!Cs_CommonFunction.IsUserLoggedIn())
            {
                return(new List <Cs_OnlineUser>());
            }
            Cs_Friend            cs_Friend     = new Cs_Friend();
            int                  UserID        = (int)Session["UserID"];
            List <Cs_OnlineUser> list_AllUser  = cs_Friend.GetOnlineFriend(UserID);
            string               currentUserID = Session["UserID"].ToString();
            List <Cs_OnlineUser> list_User     = (from p in list_AllUser
                                                  where p.UserID != currentUserID
                                                  select p).ToList();

            return(list_User);
        }
Esempio n. 5
0
        public List <object> SearchFrindList(string searchTerm)
        {
            Cs_Friend cs_friend = new Cs_Friend();
            string    userID    = Convert.ToString(Session["UserID"]);

            DataTable dt = cs_friend.SearchFriend(searchTerm, userID);

            List <object> listObject = new List <object>();

            foreach (DataRow dr in dt.Rows)
            {
                listObject.Add(new { Image = Cs_CommonFunction.RelativePath + "UserImages/" + dr["Image"].ToString(), UserName = dr["UserName"].ToString(), UserID = dr["UserID"].ToString() });
            }
            return(listObject);
            //if (dt.Rows.Count > 0)
            //{
            //    Table tbl = new Table();
            //    tbl.Attributes.Add("Width", "100%");
            //    tbl.CssClass = "tblSearch";
            //    tbl.CellPadding = 0;
            //    tbl.CellSpacing = 0;

            //    for (int i = 0; i < dt.Rows.Count; i++)
            //    {
            //        TableRow tblRow = new TableRow();
            //        TableRow tblRow2 = new TableRow();

            //        TableCell tblCellImg = new TableCell();
            //        tblCellImg.Width = 30;
            //        Image img = new Image();
            //        img.ID = "usrImg" + i;
            //        img.Height = 40;
            //        img.Width = 40;
            //        if (Convert.ToString(dt.Rows[i]["Image"]) != "")
            //        {
            //            img.ImageUrl = Cs_CommonFunction.RelativePath + "UserImages/" + Convert.ToString(dt.Rows[i]["Image"]);
            //        }
            //        else
            //        {
            //            img.ImageUrl = Cs_CommonFunction.RelativePath + "UserImages/" + "LotusFlower.jpeg";
            //        }
            //        tblCellImg.Controls.Add(img);

            //        TableCell tblCell0 = new TableCell();
            //        tblCell0.Width = 20;
            //        Label lblName = new Label();
            //        lblName.ID = "lnkButton" + i;
            //        lblName.Text = Convert.ToString(dt.Rows[i]["UserName"]).Trim();
            //        tblCell0.Controls.Add(lblName);

            //        TableCell tblCell = new TableCell();
            //        tblCell.Width = 20;
            //        int sendRequest = 1;

            //        if (string.IsNullOrEmpty(Convert.ToString(dt.Rows[i]["RequestStatus"])) || Convert.ToString(dt.Rows[i]["RequestStatus"]) == "3")
            //        {
            //            if (Convert.ToString(dt.Rows[i]["RequestStatus"]) == "3")
            //            {
            //                LinkButton lnkSendRequest = new LinkButton();
            //                lnkSendRequest.ID = "lnkButton2" + i;
            //                lnkSendRequest.ForeColor = System.Drawing.Color.Blue;
            //                lnkSendRequest.Text = "Request Sent";
            //                lnkSendRequest.Attributes.Add("href", "javascript:void(0);");
            //                lnkSendRequest.OnClientClick = "false;";
            //                tblCell.Controls.Add(lnkSendRequest);
            //            }
            //            else
            //            {
            //                LinkButton lnkSendRequest = new LinkButton();
            //                lnkSendRequest.ID = "lnkButton2" + i;
            //                lnkSendRequest.ForeColor = System.Drawing.Color.Green;
            //                lnkSendRequest.Text = "Send Request";
            //                lnkSendRequest.OnClientClick = "return sendFriendRequest(" + Convert.ToString(dt.Rows[i]["UserID"]) + ",this)";
            //                tblCell.Controls.Add(lnkSendRequest);
            //            }
            //        }
            //        else
            //        {
            //            sendRequest = 0;
            //        }


            //        TableCell tblCell1 = new TableCell();
            //        tblCell1.Width = 30;
            //        LinkButton lnkViewProfile = new LinkButton();
            //        lnkViewProfile.ID = "lnkButton3" + i;
            //        lnkViewProfile.Text = "View Profile";
            //        lnkViewProfile.OnClientClick = "window.location.href='Profile.aspx?Request=" + sendRequest + "&UserID=" + Convert.ToString(dt.Rows[i]["UserID"]) + "';";
            //        tblCell1.Controls.Add(lnkViewProfile);

            //        tblRow.Controls.Add(tblCellImg);
            //        tblRow.Controls.Add(tblCell0);
            //        tblRow.Controls.Add(tblCell);
            //        tblRow.Controls.Add(tblCell1);
            //        tblRow.Attributes.Add("style", "border:1px solid gray; background-color:silver;");

            //        TableCell cell = new TableCell();
            //        cell.ID = "cell" + i;
            //        cell.ColumnSpan = 4;
            //        cell.Text = "<b>City</b>&nbsp;&nbsp;:" + Convert.ToString(dt.Rows[i]["City"]);
            //        cell.Text += "<br><b>Country</b>&nbsp;&nbsp;:" + Convert.ToString(dt.Rows[i]["Country"]);


            //        tbl.Controls.Add(tblRow);
            //    }
            //    pnlResult.Controls.Add(tbl);
            //}
        }
Esempio n. 6
0
        protected void btnFriendSearch_Click(object sender, EventArgs e)
        {
            Cs_Friend cs_friend = new Cs_Friend();
            string    userID    = Convert.ToString(Session["UserID"]);

            DataTable dt = cs_friend.SearchFriend(txtFriendSearch.Text.Trim(), userID);

            if (dt.Rows.Count > 0)
            {
                Table tbl = new Table();
                tbl.Attributes.Add("Width", "100%");
                tbl.CssClass    = "tblSearch";
                tbl.CellPadding = 0;
                tbl.CellSpacing = 0;

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    TableRow tblRow  = new TableRow();
                    TableRow tblRow2 = new TableRow();

                    TableCell tblCellImg = new TableCell();
                    tblCellImg.Width = 30;
                    Image img = new Image();
                    img.ID     = "usrImg" + i;
                    img.Height = 40;
                    img.Width  = 40;
                    if (Convert.ToString(dt.Rows[i]["Image"]) != "")
                    {
                        img.ImageUrl = Cs_CommonFunction.RelativePath + "UserImages/" + Convert.ToString(dt.Rows[i]["Image"]);
                    }
                    else
                    {
                        img.ImageUrl = Cs_CommonFunction.RelativePath + "UserImages/" + "LotusFlower.jpeg";
                    }
                    tblCellImg.Controls.Add(img);

                    TableCell tblCell0 = new TableCell();
                    tblCell0.Width = 20;
                    Label lblName = new Label();
                    lblName.ID   = "lnkButton" + i;
                    lblName.Text = Convert.ToString(dt.Rows[i]["UserName"]).Trim();
                    tblCell0.Controls.Add(lblName);

                    TableCell tblCell = new TableCell();
                    tblCell.Width = 20;
                    int sendRequest = 1;

                    if (string.IsNullOrEmpty(Convert.ToString(dt.Rows[i]["RequestStatus"])) || Convert.ToString(dt.Rows[i]["RequestStatus"]) == "3")
                    {
                        if (Convert.ToString(dt.Rows[i]["RequestStatus"]) == "3")
                        {
                            LinkButton lnkSendRequest = new LinkButton();
                            lnkSendRequest.ID        = "lnkButton2" + i;
                            lnkSendRequest.ForeColor = System.Drawing.Color.Blue;
                            lnkSendRequest.Text      = "Request Sent";
                            lnkSendRequest.Attributes.Add("href", "javascript:void(0);");
                            lnkSendRequest.OnClientClick = "false;";
                            tblCell.Controls.Add(lnkSendRequest);
                        }
                        else
                        {
                            LinkButton lnkSendRequest = new LinkButton();
                            lnkSendRequest.ID            = "lnkButton2" + i;
                            lnkSendRequest.ForeColor     = System.Drawing.Color.Green;
                            lnkSendRequest.Text          = "Send Request";
                            lnkSendRequest.OnClientClick = "return sendFriendRequest(" + Convert.ToString(dt.Rows[i]["UserID"]) + ",this)";
                            tblCell.Controls.Add(lnkSendRequest);
                        }
                    }
                    else
                    {
                        sendRequest = 0;
                    }


                    TableCell tblCell1 = new TableCell();
                    tblCell1.Width = 30;
                    LinkButton lnkViewProfile = new LinkButton();
                    lnkViewProfile.ID            = "lnkButton3" + i;
                    lnkViewProfile.Text          = "View Profile";
                    lnkViewProfile.OnClientClick = "window.location.href='Profile.aspx?Request=" + sendRequest + "&UserID=" + Convert.ToString(dt.Rows[i]["UserID"]) + "';";
                    tblCell1.Controls.Add(lnkViewProfile);

                    tblRow.Controls.Add(tblCellImg);
                    tblRow.Controls.Add(tblCell0);
                    tblRow.Controls.Add(tblCell);
                    tblRow.Controls.Add(tblCell1);
                    tblRow.Attributes.Add("style", "border:1px solid gray; background-color:silver;");

                    TableCell cell = new TableCell();
                    cell.ID         = "cell" + i;
                    cell.ColumnSpan = 4;
                    cell.Text       = "<b>City</b>&nbsp;&nbsp;:" + Convert.ToString(dt.Rows[i]["City"]);
                    cell.Text      += "<br><b>Country</b>&nbsp;&nbsp;:" + Convert.ToString(dt.Rows[i]["Country"]);


                    tbl.Controls.Add(tblRow);
                }
                pnlResult.Controls.Add(tbl);
            }
        }