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"; } } } }
public static List <Newsfeed> RankNewsFeed(List <Newsfeed> lst) { foreach (var post in lst) { post.AffinityScore = 0; post.PostWeight = 0; if (post.Type == Global.PHOTO || post.Type == Global.TAG_PHOTO) { post.PostWeight += Global.WEIGHT_PHOTO; } else if (post.Type == Global.VIDEO || post.Type == Global.TAG_VIDEO) { post.PostWeight += Global.WEIGHT_VIDEO; } else if (post.Type == Global.TAG_VIDEOLINK) { post.PostWeight += Global.WEIGHT_VIDEOLINK; } else if (post.Type == Global.TEXT_POST) { post.PostWeight += Global.WEIGHT_TEXT; } long likesCount = LikesDAL.countPost(post._id.ToString(), Global.WALL); long sharesCount = ShareDAL.countPost(post._id.ToString(), Global.WALL); long commentsCount = CommentsDAL.countComment(post._id.ToString(), Global.WALL); post.PostWeight += (int)likesCount; post.PostWeight += (int)sharesCount; post.PostWeight += (int)commentsCount; post.PostRank = post.PostWeight + post.AffinityScore; } return(lst); }
///////////////////////////////////////////////////////////////////////////////////////////////////////////// /// 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"; } } }