// To share a post protected void ShareLinkButton_Click(object sender, EventArgs e) { GridViewRow row = ((GridViewRow)((LinkButton)sender).NamingContainer); LinkButton linkShare = (LinkButton)row.FindControl("ShareLinkButton"); Label labelShare = (Label)row.FindControl("ShareLabel"); HiddenField hfId = (HiddenField)row.FindControl("HiddenFieldId"); if (linkShare.Text == "Share") { // UserBO objUser = new UserBO(); objUser = UserBLL.getUserByUserId(Session["UserId"].ToString()); ShareBO objClass = new ShareBO(); objClass.AtId = hfId.Value; objClass.Type = Global.WALL; objClass.UserId = Session["UserId"].ToString(); objClass.FirstName = objUser.FirstName; objClass.LastName = objUser.LastName; ShareBLL.insertShare(objClass); //////////////////////////////////////////////////////////////////////////// // Put "follow" record for each user that has been tagged, traverse the list FollowPostBO objFollow = new FollowPostBO(); objFollow.AtId = hfId.Value; objFollow.Type = Global.WALL; objFollow.UserId = Session["hello"].ToString(); objFollow.FirstName = objUser.FirstName; objFollow.LastName = objUser.LastName; FollowPostBLL.insertFollowPost(objFollow); //////////////////////////////////////////////////////////////////////////// labelShare.Text = "You have shared this."; WallBO wall = WallBLL.getWallByWallId(objClass.AtId); string p = ShareDescriptionTextBox.Text + " <br/>" + wall.Post; ShareStatus(p); } else { LikesBO objClass = new LikesBO(); objClass.AtId = hfId.Value; objClass.Type = Global.WALL; objClass.UserId = Session["UserId"].ToString(); LikesBLL.unLikes(objClass); labelShare.Text = ""; linkShare.Text = "Like"; } LoadWall(50); }
protected void ShareStatus(string post) { string status = post; if (lblFriendsWith.Text != "") { status += " with " + lblFriendsWith.Text.Remove(lblFriendsWith.Text.LastIndexOf(",")); } if (lblLocation.Text != "") { status += lblLocation.Text; } UserBO objUser = new UserBO(); objUser = UserBLL.getUserByUserId(SessionClass.getUserId()); WallBO objWall = new WallBO(); string PostedByUserId = SessionClass.getUserId(); string WallOwnerUserId = string.Empty; if (SessionClass.getShareWithID() != null) { PostedByUserId = Session["UserId"].ToString(); if (SessionClass.getShareWithID() != "") { WallOwnerUserId = SessionClass.getShareWithID(); UserBO objFriendObj = new UserBO(); objFriendObj = UserBLL.getUserByUserId(SessionClass.getShareWithID()); if (!CheckBox1.Checked) { ThreadPool.QueueUserWorkItem(new WaitCallback(sendEmail), (object)objFriendObj.Email); notif(SessionClass.getShareWithID(), SessionClass.getPostID()); } List <string> temp = (List <string>)SessionClass.getTaggedFriends(); if (temp != null) { foreach (string str in temp) { UserBO objFriendObj1 = new UserBO(); objFriendObj1 = UserBLL.getUserByUserId(str); //sendEmail(objFriendObj1.Email); if (!CheckBox1.Checked) { ThreadPool.QueueUserWorkItem(new WaitCallback(sendEmail), (object)objFriendObj1.Email); notif(str, SessionClass.getPostID()); } //Inserting follow post record for each tagged user FollowPostBO fp = new FollowPostBO(); fp.AtId = SessionClass.getPostID(); fp.UserId = objFriendObj1.Id; fp.FirstName = objFriendObj1.FirstName; fp.LastName = objFriendObj1.LastName; fp.Type = Global.WALL; FollowPostBLL.insertFollowPost(fp); } } } else { WallOwnerUserId = SessionClass.getUserId(); UserBO objUserEmail = new UserBO(); objUserEmail = UserBLL.getUserByUserId(SessionClass.getUserId()); // Sending notification with which the post is beind shared if (!CheckBox1.Checked) { ThreadPool.QueueUserWorkItem(new WaitCallback(sendEmail), (object)objUserEmail.Email); notif(SessionClass.getShareWithID(), SessionClass.getPostID()); } //Sending notification to all tagged friends List <string> temp = (List <string>)SessionClass.getTaggedFriends(); if (temp != null) { foreach (string str in temp) { UserBO objFriendObj1 = new UserBO(); objFriendObj1 = UserBLL.getUserByUserId(str); if (!CheckBox1.Checked) { ThreadPool.QueueUserWorkItem(new WaitCallback(sendEmail), (object)objFriendObj1.Email); } notif(str, SessionClass.getPostID()); //Inserting follow post record for each tagged user FollowPostBO fp = new FollowPostBO(); fp.AtId = SessionClass.getPostID(); fp.UserId = objFriendObj1.Id; fp.FirstName = objFriendObj1.FirstName; fp.LastName = objFriendObj1.LastName; fp.Type = Global.WALL; FollowPostBLL.insertFollowPost(fp); } } } } else { WallOwnerUserId = SessionClass.getUserId(); UserBO objUserEmail = new UserBO(); objUserEmail = UserBLL.getUserByUserId(SessionClass.getUserId()); if (!CheckBox1.Checked) { ThreadPool.QueueUserWorkItem(new WaitCallback(sendEmail), (object)objUserEmail.Email); } //Sending notification to all tagged friends List <string> temp = (List <string>)SessionClass.getTaggedFriends(); if (temp != null) { foreach (string str in temp) { UserBO objFriendObj1 = new UserBO(); objFriendObj1 = UserBLL.getUserByUserId(str); // sendEmail(objFriendObj1.Email); if (!CheckBox1.Checked) { ThreadPool.QueueUserWorkItem(new WaitCallback(sendEmail), (object)objFriendObj1.Email); notif(str, SessionClass.getPostID()); } //Inserting follow post record for each tagged user FollowPostBO fp = new FollowPostBO(); fp.AtId = SessionClass.getPostID(); fp.UserId = objFriendObj1.Id; fp.FirstName = objFriendObj1.FirstName; fp.LastName = objFriendObj1.LastName; fp.Type = Global.WALL; FollowPostBLL.insertFollowPost(fp); } } } PostProperties postProp = new PostProperties(); postProp.PostText = "Share a post " + status; postProp.WallOwnerUserId = WallOwnerUserId; postProp.PostedByUserId = PostedByUserId; postProp.PostType = SessionClass.getPostType(); postProp.EmbedPost = SessionClass.getEmbedPost(); PostOnWall.post(postProp); ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myScript", "document.getElementById('" + txtUpdatePost.ClientID + "').value = '';", true); lblLocation.Text = ""; lblFriendsWith.Text = ""; LoadWall(100); Session["ShareWithID"] = ""; Session["TaggedFriends"] = null; }