protected void lbtnLike_Click(object sender, EventArgs e) { if (lbtnLike.Text == "Like") { UserBO objUser = new UserBO(); objUser = UserBLL.getUserByUserId(Userid); LikesBO objClass = new LikesBO(); objClass.AtId = Photoid; objClass.Type = Global.VIDEO; objClass.UserId = Userid; objClass.FirstName = objUser.FirstName; objClass.LastName = objUser.LastName; LikesBLL.insertLikes(objClass); lblLike.Text = "You Like this"; lbtnLike.Text = "UnLike"; } else { LikesBO objClass = new LikesBO(); objClass.AtId = Photoid; objClass.Type = Global.VIDEO; objClass.UserId = Userid; LikesBLL.unLikes(objClass); lblLike.Text = ""; lbtnLike.Text = "Like"; } }
protected void lbtnCommentLike_Click(object sender, EventArgs e) { GridViewRow row = ((GridViewRow)((LinkButton)sender).NamingContainer); HiddenField hfId = (HiddenField)row.FindControl("HiddenFieldId"); LinkButton lbtnCommentLike = (LinkButton)row.FindControl("lbtnCommentLike"); if (lbtnCommentLike.Text == "Like") { UserBO objUser = new UserBO(); objUser = UserBLL.getUserByUserId(Session["UserId"].ToString()); LikesBO objClass = new LikesBO(); objClass.AtId = hfId.Value; objClass.Type = Global.WALL_COMMENT; objClass.UserId = Session["UserId"].ToString(); objClass.FirstName = objUser.FirstName; objClass.LastName = objUser.LastName; LikesBLL.insertLikes(objClass); lbtnCommentLike.Text = "You Like this"; lbtnCommentLike.Text = "UnLike"; } else { LikesBO objClass = new LikesBO(); objClass.AtId = hfId.Value; objClass.Type = Global.WALL_COMMENT; objClass.UserId = Session["UserId"].ToString(); LikesBLL.unLikes(objClass); lbtnCommentLike.Text = ""; lbtnCommentLike.Text = "Like"; } LoadWall(50); }
protected void Comment_YouLikes(GridViewRow row) { GridView gridviewcomment = (GridView)row.FindControl("GridViewComments"); foreach (GridViewRow gvr in gridviewcomment.Rows) { if (gvr.RowType == DataControlRowType.DataRow) { LinkButton linkLike = (LinkButton)gvr.FindControl("lbtnCommentLike"); Label labelLike = (Label)gvr.FindControl("lblCommentLike"); LinkButton linkLikeCount = (LinkButton)gvr.FindControl("lbtnCommentLikeUser"); HiddenField hfId = (HiddenField)gvr.FindControl("HiddenFieldId"); HiddenField hfdate = (HiddenField)gvr.FindControl("HiddenFieldCommentAddedDate"); Label labeldate = (Label)gvr.FindControl("lblCommentAddedDate"); DateTime date = Convert.ToDateTime(hfdate.Value); labeldate.Text = TimeAgo(date); long likecount = LikesBLL.countPost(hfId.Value, Global.WALL_COMMENT); if (likecount > 0) { linkLikeCount.Text = likecount.ToString() + " Users"; } else { linkLikeCount.Visible = false; } HiddenField Userownid = (HiddenField)gvr.FindControl("HiddenFieldCommentUserId"); LinkButton lbtnDeleteComment = (LinkButton)gvr.FindControl("lbtnDeleteComment"); if (Userownid.Value.Equals(Session["UserId"].ToString())) { lbtnDeleteComment.Visible = true; } LikesBO objClass = new LikesBO(); objClass.AtId = hfId.Value; objClass.Type = Global.WALL_COMMENT; objClass.UserId = Session["UserId"].ToString(); bool islike = LikesBLL.youLikes(objClass); if (islike) { labelLike.Text = ""; linkLike.Text = "UnLike"; } else { labelLike.Text = ""; linkLike.Text = "Like"; } } } }
public int Agregar(LikesBO Like) { SqlCommand Comando = new SqlCommand("insert into Likes values(@Usuario, @Publicacion)"); Comando.Parameters.Add("@Usuario", SqlDbType.Int).Value = Like.CodigoUsuario13; Comando.Parameters.Add("@Publicacion", SqlDbType.Int).Value = Like.CodigoPublicacion; return(Conexion.EjecutarComando(Comando)); }
public static void unLikes(LikesBO objClass) { MongoCollection <Likes> objCollection = db.GetCollection <Likes>("c_Likes"); var query = Query.And( Query.EQ("Type", objClass.Type), Query.EQ("AtId", ObjectId.Parse(objClass.AtId)), Query.EQ("UserId", ObjectId.Parse(objClass.UserId))); var result = objCollection.FindAndRemove(query, SortBy.Ascending("_id")); }
///////////////////////////////////////////////////////////////////////////////////////////////////////////// /// COMMENTS LIKE MODULE //// //////////////////////////////////////////////////////////////////////////////////////////////////////////// // @@@@@@@@@@@@@@@@@@@@ by Nabeel protected void lbtnCommentLike_Click(object sender, EventArgs e) { GridViewRow row = ((GridViewRow)((LinkButton)sender).NamingContainer); HiddenField hfId = (HiddenField)row.FindControl("HiddenFieldId"); LinkButton lbtnCommentLike = (LinkButton)row.FindControl("lbtnCommentLike"); //GridView gv = (GridView)GridViewWall.Rows[RowIndex].FindControl("GridViewComments"); UserBO objUser = new UserBO(); objUser = UserBLL.getUserByUserId(Session["UserId"].ToString()); if (lbtnCommentLike.Text == "Like") { LikesBO objClass = new LikesBO(); objClass.AtId = hfId.Value; objClass.Type = Global.WALL_COMMENT; objClass.UserId = Session["UserId"].ToString(); objClass.FirstName = objUser.FirstName; objClass.LastName = objUser.LastName; LikesBLL.insertLikes(objClass); lbtnCommentLike.Text = ""; lbtnCommentLike.Text = "UnLike"; } else { LikesBO objClass = new LikesBO(); objClass.AtId = hfId.Value; objClass.Type = Global.WALL_COMMENT; objClass.UserId = Session["UserId"].ToString(); LikesBLL.unLikes(objClass); lbtnCommentLike.Text = ""; lbtnCommentLike.Text = "Like"; } // // Comment_YouLikes(); /////////////////////////////////////Friends recent activities if (!userid.Equals(Session["UserId"].ToString())) { UserBO objFUser = new UserBO(); objFUser = UserBLL.getUserByUserId(userid); WallBO objWall = new WallBO(); objWall.PostedByUserId = Session["UserId"].ToString(); objWall.WallOwnerUserId = Session["UserId"].ToString(); objWall.FirstName = objUser.FirstName; objWall.LastName = objUser.LastName; objWall.Post = " Like a Comments on <a href=\"ViewProfile.aspx?UserId=" + userid + "\">" + objFUser.FirstName + " " + objFUser.LastName + "</a> Wall Post"; objWall.AddedDate = DateTime.Now; objWall.Type = Global.PROFILE_CHANGE; WallBLL.insertWall(objWall); } //////////////////////////////////////// // Response.Redirect("main.aspx?c="+hfId.Value); }
protected void YouLikes() { foreach (GridViewRow gvr in GridViewWall.Rows) { if (gvr.RowType == DataControlRowType.DataRow) { LinkButton linkLike = (LinkButton)gvr.FindControl("lbtnLike"); Label labelLike = (Label)gvr.FindControl("lblLike"); LinkButton linkLikeCount = (LinkButton)gvr.FindControl("lbtnUser"); HiddenField hfId = (HiddenField)gvr.FindControl("HiddenFieldId"); long likecount = LikesBLL.countPost(hfId.Value, Global.WALL); if (likecount > 0) { linkLikeCount.Text = likecount.ToString() + " Users"; } else { linkLikeCount.Visible = false; } LinkButton linkcountComments = (LinkButton)gvr.FindControl("lbtnViewComments"); long totalcomments = CommentsDAL.countComment(hfId.Value, Global.WALL); if (totalcomments > 2) { linkcountComments.Text = "View All " + totalcomments.ToString() + " Comments"; } else { linkcountComments.Visible = false; } LikesBO objClass = new LikesBO(); objClass.AtId = hfId.Value; objClass.Type = Global.WALL; objClass.UserId = Session["UserId"].ToString(); bool islike = LikesBLL.youLikes(objClass); if (islike) { labelLike.Text = "You Like This"; linkLike.Text = "UnLike"; } else { labelLike.Text = ""; linkLike.Text = "Like"; } } } }
// 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); }
public static void updateLikes(LikesBO objClass) { MongoCollection <Likes> objCollection = db.GetCollection <Likes>("c_Likes"); var query = Query.EQ("_id", ObjectId.Parse(objClass.Id)); var sortBy = SortBy.Descending("_id"); var update = Update.Set("UserId", ObjectId.Parse(objClass.UserId)) .Set("AtId", ObjectId.Parse(objClass.AtId)) .Set("Type", objClass.Type) .Set("FirstName", objClass.FirstName) .Set("LastName", objClass.LastName) ; var result = objCollection.FindAndModify(query, sortBy, update, true); }
public static LikesBO getLikesByLikesId(string Id) { MongoCollection<Likes> objCollection = db.GetCollection<Likes>("c_Likes"); LikesBO objClass = new LikesBO(); foreach (Likes item in objCollection.Find(Query.EQ("_id", ObjectId.Parse(Id)))) { objClass.Id = item._id.ToString(); objClass.UserId = item.UserId.ToString(); objClass.AtId= item.AtId.ToString(); objClass.Type = item.Type; objClass.FirstName = item.FirstName; objClass.LastName = item.LastName; break; } return objClass; }
public static LikesBO getLikesByLikesId(string Id) { MongoCollection <Likes> objCollection = db.GetCollection <Likes>("c_Likes"); LikesBO objClass = new LikesBO(); foreach (Likes item in objCollection.Find(Query.EQ("_id", ObjectId.Parse(Id)))) { objClass.Id = item._id.ToString(); objClass.UserId = item.UserId.ToString(); objClass.AtId = item.AtId.ToString(); objClass.Type = item.Type; objClass.FirstName = item.FirstName; objClass.LastName = item.LastName; break; } return(objClass); }
public static bool youLikes(LikesBO objClass) { MongoCollection <BsonDocument> objCollection = db.GetCollection <BsonDocument>("c_Likes"); var query = Query.And( Query.EQ("Type", objClass.Type), Query.EQ("AtId", ObjectId.Parse(objClass.AtId)), Query.EQ("UserId", ObjectId.Parse(objClass.UserId))); var result = objCollection.Find(query); if (result.Any()) { return(true); } else { return(false); } }
protected void YouLikes() { LikesBO objClass = new LikesBO(); objClass.AtId = Photoid; objClass.Type = Global.VIDEO; objClass.UserId = Userid; bool islike = LikesBLL.youLikes(objClass); if (islike) { lblLike.Text = "You Like This"; lbtnLike.Text = "UnLike"; } else { lblLike.Text = ""; lbtnLike.Text = "Like"; } }
public static void insertLikes(LikesBO objClass) { MongoCollection <BsonDocument> objCollection = db.GetCollection <BsonDocument>("c_Likes"); var query = Query.And( Query.EQ("Type", objClass.Type), Query.EQ("AtId", ObjectId.Parse(objClass.AtId)), Query.EQ("UserId", ObjectId.Parse(objClass.UserId))); var result = objCollection.Find(query); if (!result.Any()) { BsonDocument doc = new BsonDocument { { "UserId", ObjectId.Parse(objClass.UserId) }, { "AtId", ObjectId.Parse(objClass.AtId) }, { "Type", objClass.Type }, { "FirstName", objClass.FirstName }, { "LastName", objClass.LastName }, { "AddedDate", DateTime.Now }, }; var rt = objCollection.Insert(doc); } }
public static void unLikes(LikesBO objClass) { LikesDAL.unLikes(objClass); }
public static bool youLikes(LikesBO objClass) { return LikesDAL.youLikes(objClass); }
public static void insertLikes(LikesBO objLikes) { LikesDAL.insertLikes(objLikes); }
public static void updateLikes(LikesBO objLikes) { LikesDAL.updateLikes(objLikes); }
protected void lbtnLike_Click(object sender, EventArgs e) { string statuslike = "like a post"; GridViewRow row = ((GridViewRow)((LinkButton)sender).NamingContainer); LinkButton linkLike = (LinkButton)row.FindControl("lbtnLike"); Label labelLike = (Label)row.FindControl("lblLike"); Literal literalpost = (Literal)row.FindControl("Literal1"); HiddenField hfId = (HiddenField)row.FindControl("HiddenFieldWallId"); HiddenField hfType = (HiddenField)row.FindControl("HiddenFieldType"); HiddenField hfEmbedPost = (HiddenField)row.FindControl("HiddenFieldEmbedTickerPost"); PopupControlExtender pce = row.FindControl("PopupControlExtenderTicker") as PopupControlExtender; UserBO objUser = new UserBO(); objUser = UserBLL.getUserByUserId(Session["UserId"].ToString()); if (linkLike.Text == "Like") { LikesBO objClass = new LikesBO(); objClass.AtId = hfId.Value; objClass.Type = Global.WALL; objClass.UserId = Session["UserId"].ToString(); objClass.FirstName = objUser.FirstName; objClass.LastName = objUser.LastName; LikesBLL.insertLikes(objClass); labelLike.Text = ""; linkLike.Text = "UnLike"; statuslike = "like a post"; } else { LikesBO objClass = new LikesBO(); objClass.AtId = hfId.Value; objClass.Type = Global.WALL; objClass.UserId = Session["UserId"].ToString(); LikesBLL.unLikes(objClass); labelLike.Text = ""; linkLike.Text = "Like"; statuslike = "unlike a post"; } pce.DataBind(); /////////////////////////////////////Friends recent activities if (!userid.Equals(Session["UserId"].ToString())) { UserBO objFUser = new UserBO(); objFUser = UserBLL.getUserByUserId(userid); WallBO objWall = new WallBO(); objWall.PostedByUserId = Session["UserId"].ToString(); objWall.WallOwnerUserId = Session["UserId"].ToString(); objWall.FirstName = objUser.FirstName; objWall.LastName = objUser.LastName; objWall.Post = "Like a <a href=\"ViewProfile.aspx?UserId=" + userid + "\">" + objFUser.FirstName + " " + objFUser.LastName + "</a> Wall Post"; objWall.AddedDate = DateTime.Now; objWall.Type = Global.PROFILE_CHANGE; WallBLL.insertWall(objWall); } //////////////////////////////////////// ////////////////////////////////////TICKER CODE ////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// List <UserFriendsBO> list = FriendsBLL.getAllFriendsListName(Session["UserId"].ToString(), Global.CONFIRMED); //get the education,hometown and employer of people in list foreach (UserFriendsBO Useritem in list) { TickerBO objTicker = new TickerBO(); objTicker.PostedByUserId = Session["UserId"].ToString(); objTicker.TickerOwnerUserId = Useritem.FriendUserId; objTicker.FirstName = objUser.FirstName; objTicker.LastName = objUser.LastName; objTicker.Post = literalpost.Text; objTicker.Title = statuslike; objTicker.AddedDate = DateTime.UtcNow; objTicker.Type = Convert.ToInt32(hfType.Value); objTicker.EmbedPost = hfEmbedPost.Value; objTicker.WallId = hfId.Value; TickerBLL.insertTicker(objTicker); } TickerBO objTickerUser = new TickerBO(); objTickerUser.PostedByUserId = Session["UserId"].ToString(); objTickerUser.TickerOwnerUserId = Session["UserId"].ToString(); objTickerUser.FirstName = objUser.FirstName; objTickerUser.LastName = objUser.LastName; objTickerUser.Post = literalpost.Text; objTickerUser.Title = statuslike; objTickerUser.AddedDate = DateTime.UtcNow; objTickerUser.Type = Convert.ToInt32(hfType.Value); objTickerUser.EmbedPost = hfEmbedPost.Value; objTickerUser.WallId = hfId.Value; TickerBLL.insertTicker(objTickerUser); //////////////////////////////////////////////////////////////////////////////////// }
protected void lbtnLike_Click(object sender, EventArgs e) { string statuslike = "like a post"; GridViewRow row = ((GridViewRow)((LinkButton)sender).NamingContainer); LinkButton linkLike = (LinkButton)row.FindControl("lbtnLike"); Label labelLike = (Label)row.FindControl("lblLike"); HiddenField hfId = (HiddenField)row.FindControl("HiddenFieldId"); Literal literalpost = (Literal)row.FindControl("LiteralPost"); HiddenField hfType = (HiddenField)row.FindControl("HiddenFieldType"); HiddenField hfEmbedPost = (HiddenField)row.FindControl("HiddenFieldEmbedPost"); UserBO objUser = new UserBO(); objUser = UserBLL.getUserByUserId(Session["UserId"].ToString()); if (linkLike.Text == "Like") { LikesBO objClass = new LikesBO(); objClass.AtId = hfId.Value; objClass.Type = Global.WALL; objClass.UserId = Session["UserId"].ToString(); objClass.FirstName = objUser.FirstName; objClass.LastName = objUser.LastName; LikesBLL.insertLikes(objClass); linkLike.Text = "Unlike"; statuslike = "like a post"; } else { LikesBO objClass = new LikesBO(); objClass.AtId = hfId.Value; objClass.Type = Global.WALL; objClass.UserId = Session["UserId"].ToString(); LikesBLL.unLikes(objClass); linkLike.Text = "Like"; statuslike = "unlike a post"; } LoadWall(50); /////////////////////////////////////Friends recent activities if (!userid.Equals(Session["UserId"].ToString())) { UserBO objFUser = new UserBO(); objFUser = UserBLL.getUserByUserId(userid); WallBO objWall = new WallBO(); objWall.PostedByUserId = Session["UserId"].ToString(); objWall.WallOwnerUserId = Session["UserId"].ToString(); objWall.FirstName = objUser.FirstName; objWall.LastName = objUser.LastName; objWall.Post = "Like a <a href=\"ViewProfile.aspx?UserId=" + userid + "\">" + objFUser.FirstName + " " + objFUser.LastName + "</a> Wall Post"; objWall.AddedDate = DateTime.Now; objWall.Type = Global.TEXT_POST; WallBLL.insertWall(objWall); } //////////////////////////////////////// ////////////////////////////////////TICKER CODE ////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// List<UserFriendsBO> list = FriendsBLL.getAllFriendsListName(Session["UserId"].ToString(), Global.CONFIRMED); //get the education,hometown and employer of people in list foreach (UserFriendsBO Useritem in list) { TickerBO objTicker = new TickerBO(); objTicker.PostedByUserId = Session["UserId"].ToString(); objTicker.TickerOwnerUserId = Useritem.FriendUserId; objTicker.FirstName = objUser.FirstName; objTicker.LastName = objUser.LastName; objTicker.Post = literalpost.Text; objTicker.Title = statuslike; objTicker.AddedDate = DateTime.UtcNow; objTicker.Type = Convert.ToInt32(hfType.Value); objTicker.EmbedPost = hfEmbedPost.Value; objTicker.WallId = hfId.Value; TickerBLL.insertTicker(objTicker); } TickerBO objTickerUser = new TickerBO(); objTickerUser.PostedByUserId = Session["UserId"].ToString(); objTickerUser.TickerOwnerUserId = Session["UserId"].ToString(); objTickerUser.FirstName = objUser.FirstName; objTickerUser.LastName = objUser.LastName; objTickerUser.Post = literalpost.Text; objTickerUser.Title = statuslike; objTickerUser.AddedDate = DateTime.UtcNow; objTickerUser.Type = Convert.ToInt32(hfType.Value); objTickerUser.EmbedPost = hfEmbedPost.Value; objTickerUser.WallId = hfId.Value; TickerBLL.insertTicker(objTickerUser); //////////////////////////////////////////////////////////////////////////////////// }
///////////////////////////////////////////////////////////////////////////////////////////////////////////// /// POST LIKE MODULE //// //////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void YouLikes() { foreach (GridViewRow gvr in GridViewWall.Rows) { if (gvr.RowType == DataControlRowType.DataRow) { LinkButton linkLike = (LinkButton)gvr.FindControl("lbtnLike"); Label labelLike = (Label)gvr.FindControl("lblLike"); LinkButton linkLikeCount = (LinkButton)gvr.FindControl("lbtnUser"); HiddenField hfId = (HiddenField)gvr.FindControl("HiddenFieldId"); HiddenField hfuserId = (HiddenField)gvr.FindControl("HiddenFieldUserId"); HiddenField hfdate = (HiddenField)gvr.FindControl("HiddenFieldAddedDate"); Label labeldate = (Label)gvr.FindControl("lblAddedDate"); Literal literalpost = (Literal)gvr.FindControl("LiteralPost"); ImageButton imgbtn = (ImageButton)gvr.FindControl("ImageButton1"); LinkButton linkSeeFriendShip = (LinkButton)gvr.FindControl("lbtnSeeFriendShip"); LinkButton linkShare = (LinkButton)gvr.FindControl("ShareLinkButton"); HiddenField hfType = (HiddenField)gvr.FindControl("HiddenFieldType"); DateTime date = Convert.ToDateTime(hfdate.Value); labeldate.Text=TimeAgo(date); if (Convert.ToInt32(hfType.Value) == Global.TEXT_POST || Convert.ToInt32(hfType.Value) == Global.PROFILE_CHANGE) linkShare.Visible = false; if (FriendsBLL.isExistingFriend(hfuserId.Value, Session["UserId"].ToString())) linkSeeFriendShip.Visible = true; if(literalpost.Text.IndexOf("width")>0) imgbtn.Visible = false; long likecount = LikesBLL.countPost(hfId.Value, Global.WALL); if (likecount > 0) linkLikeCount.Text = likecount.ToString() + " Likes"; else linkLikeCount.Visible = false; LinkButton linkcountComments = (LinkButton)gvr.FindControl("lbtnViewComments"); long totalcomments = CommentsDAL.countComment(hfId.Value, Global.WALL); if (totalcomments > 2) linkcountComments.Text = "View All " + totalcomments.ToString() + " Comments"; else linkcountComments.Text = totalcomments.ToString() + " Comments"; if (totalcomments <= 0) linkcountComments.Visible = false; HiddenField Userownid = (HiddenField)gvr.FindControl("HiddenFieldUserId"); LinkButton lbtnDelete = (LinkButton)gvr.FindControl("lbtnDelete"); if (Userownid.Value.Equals(Session["UserId"].ToString())) { lbtnDelete.Visible = true; } LikesBO objClass = new LikesBO(); objClass.AtId = hfId.Value; objClass.Type = Global.WALL; objClass.UserId = Session["UserId"].ToString(); bool islike = LikesBLL.youLikes(objClass); if (islike) { linkLike.Text = "Unlike"; } else { linkLike.Text = "Like"; } } } }
protected void Comment_YouLikes() { foreach (GridViewRow gvrmain in GridViewWall.Rows) { GridView gridviewcomment = (GridView)gvrmain.FindControl("GridViewComments"); foreach (GridViewRow gvr in gridviewcomment.Rows) { if (gvr.RowType == DataControlRowType.DataRow) { LinkButton linkLike = (LinkButton)gvr.FindControl("lbtnCommentLike"); Label labelLike = (Label)gvr.FindControl("lblCommentLike"); LinkButton linkLikeCount = (LinkButton)gvr.FindControl("lbtnCommentLikeUser"); HiddenField hfId = (HiddenField)gvr.FindControl("HiddenFieldId"); HiddenField hfdate = (HiddenField)gvr.FindControl("HiddenFieldCommentAddedDate"); Label labeldate = (Label)gvr.FindControl("lblCommentAddedDate"); DateTime date = Convert.ToDateTime(hfdate.Value); labeldate.Text = TimeAgo(date); long likecount = LikesBLL.countPost(hfId.Value, Global.WALL_COMMENT); if (likecount > 0) linkLikeCount.Text = likecount.ToString() + " Likes"; else linkLikeCount.Visible = false; HiddenField Userownid = (HiddenField)gvr.FindControl("HiddenFieldCommentUserId"); LinkButton lbtnDeleteComment = (LinkButton)gvr.FindControl("lbtnDeleteComment"); if (Userownid.Value.Equals(Session["UserId"].ToString())) { lbtnDeleteComment.Visible = true; } LikesBO objClass = new LikesBO(); objClass.AtId = hfId.Value; objClass.Type = Global.WALL_COMMENT; objClass.UserId = Session["UserId"].ToString(); bool islike = LikesBLL.youLikes(objClass); if (islike) { linkLike.Text = "Unlike"; } else { linkLike.Text = "Like"; } } } } }
public static void updateLikes(LikesBO objClass) { MongoCollection<Likes> objCollection = db.GetCollection<Likes>("c_Likes"); var query = Query.EQ("_id", ObjectId.Parse(objClass.Id)); var sortBy = SortBy.Descending("_id"); var update = Update.Set("UserId", ObjectId.Parse(objClass.UserId)) .Set("AtId", ObjectId.Parse(objClass.AtId)) .Set("Type", objClass.Type) .Set("FirstName", objClass.FirstName) .Set("LastName", objClass.LastName) ; var result = objCollection.FindAndModify(query, sortBy, update, true); }
///////////////////////////////////////////////////////////////////////////////////////////////////////////// /// SHARE MODULE //// //////////////////////////////////////////////////////////////////////////////////////////////////////////// // 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"); HiddenField hfType = (HiddenField)row.FindControl("HiddenFieldType"); HiddenField hfEmbedPost = (HiddenField)row.FindControl("HiddenFieldEmbedPost"); Session["PostID"] = hfId.Value; Session["EmailPostID"] = hfId.Value; Session["PostType"] = hfType.Value; Session["EmbedPost"] = hfEmbedPost.Value; if (linkShare.Text == ". Share") { Response.Redirect("SharePost.aspx?Post=" + hfId.Value); //////// Getting the user information //////UserBO objUser = new UserBO(); //////objUser = UserBLL.getUserByUserId(Session["UserId"].ToString()); //////// Creating Share object //////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; //////// Getting the post which is going to be shared //////WallBO wall = WallBLL.getWallByWallId(objClass.AtId); //////string p = txtUpdatePost.Text + " <br/>" + wall.Post; //////// Sharing the post on the wall //////ShareStatus(p); //////// Registering the Share after successful completion of the above process //////ShareBLL.insertShare(objClass); // Sending Notifications to the one with which post has been shared and the one who were tagged //////////////////////////////////////////////////////////////////////////// // 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); //////////////////////////////////////////////////////////////////////////// } 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); }
public static bool youLikes(LikesBO objClass) { MongoCollection<BsonDocument> objCollection = db.GetCollection<BsonDocument>("c_Likes"); var query = Query.And( Query.EQ("Type", objClass.Type), Query.EQ("AtId", ObjectId.Parse(objClass.AtId)), Query.EQ("UserId", ObjectId.Parse(objClass.UserId))); var result = objCollection.Find(query); if (result.Any()) return true; else return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////////////// /// POST LIKE MODULE //// //////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void YouLikes(GridViewRow gvr) { if (gvr.RowType == DataControlRowType.DataRow) { LinkButton linkLike = (LinkButton)gvr.FindControl("lbtnLike"); Label labelLike = (Label)gvr.FindControl("lblLike"); LinkButton linkLikeCount = (LinkButton)gvr.FindControl("lbtnUser"); HiddenField hfId = (HiddenField)gvr.FindControl("HiddenFieldWallId"); HiddenField hfuserId = (HiddenField)gvr.FindControl("HiddenFieldUserId"); HiddenField hfdate = (HiddenField)gvr.FindControl("HiddenFieldAddedDate"); Label labeldate = (Label)gvr.FindControl("lblAddedDate"); // Literal literalpost = (Literal)gvr.FindControl("LiteralPost"); //ImageButton imgbtn = (ImageButton)gvr.FindControl("ImageButton1"); DateTime date = Convert.ToDateTime(hfdate.Value); labeldate.Text = TimeAgo(date); //if (literalpost.Text.IndexOf("width") > 0) // imgbtn.Visible = false; long likecount = LikesBLL.countPost(hfId.Value, Global.WALL); if (likecount > 0) { linkLikeCount.Text = likecount.ToString() + " Likes"; } else { linkLikeCount.Visible = false; } LinkButton linkcountComments = (LinkButton)gvr.FindControl("lbtnViewComments"); long totalcomments = CommentsDAL.countComment(hfId.Value, Global.WALL); if (totalcomments > 2) { linkcountComments.Text = "View All " + totalcomments.ToString() + " Comments"; } else { linkcountComments.Text = totalcomments.ToString() + " Comments"; } if (totalcomments <= 0) { linkcountComments.Visible = false; } HiddenField Userownid = (HiddenField)gvr.FindControl("HiddenFieldUserId"); LinkButton lbtnDelete = (LinkButton)gvr.FindControl("lbtnDelete"); if (Userownid.Value.Equals(Session["UserId"].ToString())) { lbtnDelete.Visible = true; } LikesBO objClass = new LikesBO(); objClass.AtId = hfId.Value; objClass.Type = Global.WALL; objClass.UserId = Session["UserId"].ToString(); bool islike = LikesBLL.youLikes(objClass); if (islike) { labelLike.Text = ""; linkLike.Text = "UnLike"; } else { labelLike.Text = ""; linkLike.Text = "Like"; } } }
public static void unLikes(LikesBO objClass) { MongoCollection<Likes> objCollection = db.GetCollection<Likes>("c_Likes"); var query = Query.And( Query.EQ("Type", objClass.Type), Query.EQ("AtId", ObjectId.Parse(objClass.AtId)), Query.EQ("UserId", ObjectId.Parse(objClass.UserId))); var result = objCollection.FindAndRemove(query, SortBy.Ascending("_id")); }
protected void YouLikes() { LikesBO objClass = new LikesBO(); objClass.AtId = Photoid; objClass.Type = Global.VIDEO; objClass.UserId = Userid; bool islike= LikesBLL.youLikes(objClass); if (islike) { lblLike.Text = "You Like This"; lbtnLike.Text = "UnLike"; } else { lblLike.Text = ""; lbtnLike.Text = "Like"; } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////// /// COMMENTS LIKE MODULE //// //////////////////////////////////////////////////////////////////////////////////////////////////////////// // @@@@@@@@@@@@@@@@@@@@ by Nabeel protected void lbtnCommentLike_Click(object sender, EventArgs e) { string statuslike = "like a post"; GridViewRow row = ((GridViewRow)((LinkButton)sender).NamingContainer); HiddenField hfId = (HiddenField)row.FindControl("HiddenFieldId"); LinkButton lbtnCommentLike = (LinkButton)row.FindControl("lbtnCommentLike"); //GridView gv = (GridView)GridViewWall.Rows[RowIndex].FindControl("GridViewComments"); UserBO objUser = new UserBO(); objUser = UserBLL.getUserByUserId(Session["UserId"].ToString()); if (lbtnCommentLike.Text == "Like") { LikesBO objClass = new LikesBO(); objClass.AtId = hfId.Value; objClass.Type = Global.WALL_COMMENT; objClass.UserId = Session["UserId"].ToString(); objClass.FirstName = objUser.FirstName; objClass.LastName = objUser.LastName; LikesBLL.insertLikes(objClass); lbtnCommentLike.Text = "Like this"; lbtnCommentLike.Text = "Unlike"; statuslike = "like a post comment"; } else { LikesBO objClass = new LikesBO(); objClass.AtId = hfId.Value; objClass.Type = Global.WALL_COMMENT; objClass.UserId = Session["UserId"].ToString(); LikesBLL.unLikes(objClass); lbtnCommentLike.Text = ""; lbtnCommentLike.Text = "Like"; statuslike = "unlike a post comment"; } WallBO objWall = new WallBO(); // Comment_YouLikes(); /////////////////////////////////////Friends recent activities //if (!userid.Equals(Session["UserId"].ToString())) // { UserBO objFUser = new UserBO(); objFUser = UserBLL.getUserByUserId(userid); objWall.PostedByUserId = Session["UserId"].ToString(); objWall.WallOwnerUserId = Session["UserId"].ToString(); objWall.FirstName = objUser.FirstName; objWall.LastName = objUser.LastName; objWall.Post = " Like a Comments on <a href=\"ViewProfile.aspx?UserId=" + userid + "\">" + objFUser.FirstName + " " + objFUser.LastName + "</a> Wall Post"; objWall.AddedDate = DateTime.Now; objWall.Type = Global.TEXT_POST; WallBLL.insertWall(objWall); // } //////////////////////////////////////// ////////////////////////////////////TICKER CODE ////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// List<UserFriendsBO> list = FriendsBLL.getAllFriendsListName(Session["UserId"].ToString(), Global.CONFIRMED); //get the education,hometown and employer of people in list foreach (UserFriendsBO Useritem in list) { TickerBO objTicker = new TickerBO(); objTicker.PostedByUserId = Session["UserId"].ToString(); objTicker.TickerOwnerUserId = Useritem.FriendUserId; objTicker.FirstName = objUser.FirstName; objTicker.LastName = objUser.LastName; objTicker.Post = objWall.Post; objTicker.Title = statuslike; objTicker.AddedDate = DateTime.UtcNow; objTicker.Type = Global.TEXT_POST; objTicker.EmbedPost = ""; objTicker.WallId = hfId.Value; TickerBLL.insertTicker(objTicker); } TickerBO objTickerUser = new TickerBO(); objTickerUser.PostedByUserId = Session["UserId"].ToString(); objTickerUser.TickerOwnerUserId = Session["UserId"].ToString(); objTickerUser.FirstName = objUser.FirstName; objTickerUser.LastName = objUser.LastName; objTickerUser.Post = objWall.Post; objTickerUser.Title = statuslike; objTickerUser.AddedDate = DateTime.UtcNow; objTickerUser.Type = Global.TEXT_POST; objTickerUser.EmbedPost = ""; objTickerUser.WallId = hfId.Value; TickerBLL.insertTicker(objTickerUser); //////////////////////////////////////////////////////////////////////////////////// LoadWall(50); // Response.Redirect("main.aspx?c="+hfId.Value); }
public static void insertLikes(LikesBO objClass) { MongoCollection<BsonDocument> objCollection = db.GetCollection<BsonDocument>("c_Likes"); var query = Query.And( Query.EQ("Type", objClass.Type), Query.EQ("AtId", ObjectId.Parse(objClass.AtId)), Query.EQ("UserId", ObjectId.Parse(objClass.UserId))); var result = objCollection.Find(query); if (!result.Any()) { BsonDocument doc = new BsonDocument { { "UserId" , ObjectId.Parse(objClass.UserId) }, { "AtId" , ObjectId.Parse(objClass.AtId) }, { "Type", objClass.Type }, { "FirstName", objClass.FirstName }, { "LastName", objClass.LastName }, { "AddedDate", DateTime.Now }, }; var rt = objCollection.Insert(doc); } }
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"); HiddenField hfType = (HiddenField)row.FindControl("HiddenFieldType"); HiddenField hfEmbedPost = (HiddenField)row.FindControl("HiddenFieldEmbedPost"); Session["PostID"] = hfId.Value; Session["EmailPostID"] = hfId.Value; Session["PostType"] = hfType.Value; Session["EmbedPost"] = hfEmbedPost.Value; if (linkShare.Text == "Share") { Response.Redirect("SharePost.aspx?Post=" + hfId.Value); //////// Getting the user information //////UserBO objUser = new UserBO(); //////objUser = UserBLL.getUserByUserId(Session["UserId"].ToString()); //////// Creating Share object //////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; //////// Getting the post which is going to be shared //////WallBO wall = WallBLL.getWallByWallId(objClass.AtId); //////string p = txtUpdatePost.Text + " <br/>" + wall.Post; //////// Sharing the post on the wall //////ShareStatus(p); //////// Registering the Share after successful completion of the above process //////ShareBLL.insertShare(objClass); // Sending Notifications to the one with which post has been shared and the one who were tagged //////////////////////////////////////////////////////////////////////////// // 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); //////////////////////////////////////////////////////////////////////////// } 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"; } }