public void DeleteAPost(int postID) { NewsfeedDAL newsfeedDAL = new NewsfeedDAL(); Post aPost = new Post(postID); newsfeedDAL.FlagPost(aPost); }
public string DeleteComment(int postID, int commentID) { Context.Session["memberID"].ToString(); //like method here NewsfeedDAL dal = new NewsfeedDAL(); Comments aComment = new Comments(commentID); dal.FlagComment(aComment); Post aPost = new Post(postID); return(messageDAL.CountComments(aPost).ToString()); }
public string[] AddCommentnRefresh(int postID, string commentTxt, int lastCommentID) { NewsfeedDAL newsfeedDAL = new NewsfeedDAL(); MessagesDAL messageDAL = new MessagesDAL(); Comments comment = new Comments(); StringBuilder commentBuilder = new StringBuilder(); //Decrypting the member ID comment.MemberId = Context.Session["memberID"].ToString(); comment.CommentText = commentTxt; comment.PostId = postID; comment.Commentid = lastCommentID; messageDAL.InsertComment(comment); //Insert notification NotificationDAL notificationDAL = new NotificationDAL(); Post aPost = new Post(postID); List<Member> MemberList = new List<Member>(); MemberList = notificationDAL.GetPostOwner(aPost); string friendId = MemberList[0].MemberId; Member aFriend = new Member(friendId); Member aMember = new Member(Context.Session["memberID"].ToString()); if (aMember.MemberId != aFriend.MemberId) { notificationDAL.InsertCommentedOnPostNotification(aMember, aFriend, aPost); } //Refreshing the Comment count Post post = new Post(); post.PostId = comment.PostId; //################################### //refreshing Comments //################################### DataTable comments = newsfeedDAL.GetRefreshComments(post, comment); foreach (DataRow row in comments.Rows) { date = Convert.ToDateTime(row["CreateDate"]).ToString("M"); //Building single message view box commentBuilder.Append("<div id='"); commentBuilder.Append((row["CommentID"]).ToString()); commentBuilder.Append("' class='aComment'><div class='deleteComment floatright'>"); if ((row["MemberID"]).ToString() == Session["memberID"].ToString()) { commentBuilder.Append("<a class='btnDleteComment ui-icon ui-icon-close tip' title='Delete this comment'></a>"); } else { commentBuilder.Append("<a class='btnOpenMenuComment ui-icon ui-icon-circle-triangle-s tip' title='More options..'></a>"); } commentBuilder.Append("</div><h5><a style='font-weight:normal;' "); commentBuilder.Append("id='" + (row["MemberID"]).ToString() + "'> "); commentBuilder.Append(row["Friend"].ToString()); commentBuilder.Append("</a><span class='DateWithTime ui-corner-all floatright'>"); Reusable_Methods reusable_Methods = new Reusable_Methods(); date = reusable_Methods.FormatDateTime(Convert.ToDateTime(row["CreateDate"])); commentBuilder.Append(date); commentBuilder.Append("</span></h5><p>"); commentBuilder.Append((row["CommentText"]).ToString()); commentBuilder.Append("</p></div>"); //End Building } //Array with the //number of commeents //new comments var comentArray = new string[] { messageDAL.CountComments(post).ToString(), commentBuilder.ToString()}; return comentArray; }
public string DeleteComment(int postID, int commentID) { Context.Session["memberID"].ToString(); //like method here NewsfeedDAL dal = new NewsfeedDAL(); Comments aComment = new Comments(commentID); dal.FlagComment(aComment); Post aPost = new Post(postID); return messageDAL.CountComments(aPost).ToString(); }
public string[] AddCommentnRefresh(int postID, string commentTxt, int lastCommentID) { NewsfeedDAL newsfeedDAL = new NewsfeedDAL(); MessagesDAL messageDAL = new MessagesDAL(); Comments comment = new Comments(); StringBuilder commentBuilder = new StringBuilder(); //Decrypting the member ID comment.MemberId = Context.Session["memberID"].ToString(); comment.CommentText = commentTxt; comment.PostId = postID; comment.Commentid = lastCommentID; messageDAL.InsertComment(comment); //Insert notification NotificationDAL notificationDAL = new NotificationDAL(); Post aPost = new Post(postID); List <Member> MemberList = new List <Member>(); MemberList = notificationDAL.GetPostOwner(aPost); string friendId = MemberList[0].MemberId; Member aFriend = new Member(friendId); Member aMember = new Member(Context.Session["memberID"].ToString()); if (aMember.MemberId != aFriend.MemberId) { notificationDAL.InsertCommentedOnPostNotification(aMember, aFriend, aPost); } //Refreshing the Comment count Post post = new Post(); post.PostId = comment.PostId; //################################### //refreshing Comments //################################### DataTable comments = newsfeedDAL.GetRefreshComments(post, comment); foreach (DataRow row in comments.Rows) { date = Convert.ToDateTime(row["CreateDate"]).ToString("M"); //Building single message view box commentBuilder.Append("<div id='"); commentBuilder.Append((row["CommentID"]).ToString()); commentBuilder.Append("' class='aComment'><div class='deleteComment floatright'>"); if ((row["MemberID"]).ToString() == Session["memberID"].ToString()) { commentBuilder.Append("<a class='btnDleteComment ui-icon ui-icon-close tip' title='Delete this comment'></a>"); } else { commentBuilder.Append("<a class='btnOpenMenuComment ui-icon ui-icon-circle-triangle-s tip' title='More options..'></a>"); } commentBuilder.Append("</div><h5><a style='font-weight:normal;' "); commentBuilder.Append("id='" + (row["MemberID"]).ToString() + "'> "); commentBuilder.Append(row["Friend"].ToString()); commentBuilder.Append("</a><span class='DateWithTime ui-corner-all floatright'>"); Reusable_Methods reusable_Methods = new Reusable_Methods(); date = reusable_Methods.FormatDateTime(Convert.ToDateTime(row["CreateDate"])); commentBuilder.Append(date); commentBuilder.Append("</span></h5><p>"); commentBuilder.Append((row["CommentText"]).ToString()); commentBuilder.Append("</p></div>"); //End Building } //Array with the //number of commeents //new comments var comentArray = new string[] { messageDAL.CountComments(post).ToString(), commentBuilder.ToString() }; return(comentArray); }