public static bool Delete(int threadId) { bool status = false; ForumThread forumThread = new ForumThread(threadId); DataTable dataTable = new DataTable(); dataTable.Columns.Add("PostID", typeof(int)); using (IDataReader reader = DBForums.ForumThreadGetPosts(threadId)) { while (reader.Read()) { DataRow row = dataTable.NewRow(); row["PostID"] = reader["PostID"]; dataTable.Rows.Add(row); } } foreach (DataRow row in dataTable.Rows) { forumThread.DeletePost(Convert.ToInt32(row["PostID"])); } status = DBForums.ForumThreadDelete(threadId); return(status); }
private void btnDelete_Click(object sender, EventArgs e) { ForumThread thread = new ForumThread(threadId,postId); bool userCanEditPost = false; if (isModerator || ((this.theUser != null) && (this.theUser.UserId == thread.PostUserId) && (thread.ForumId == forumId)) ) { userCanEditPost = true; } if (!userCanEditPost) { WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl()); return; } thread.ContentChanged += new ContentChangedEventHandler(thread_ContentChanged); if(thread.DeletePost(postId)) { CurrentPage.UpdateLastModifiedTime(); if (thread.PostUserId > -1) { Forum.UpdateUserStats(thread.PostUserId); } SiteUtils.QueueIndexing(); } if (hdnReturnUrl.Value.Length > 0) { WebUtils.SetupRedirect(this, hdnReturnUrl.Value); return; } WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl()); }
public static bool Delete(int threadId) { bool status = false; ForumThread forumThread = new ForumThread(threadId); DataTable dataTable = new DataTable(); dataTable.Columns.Add("PostID", typeof(int)); using (IDataReader reader = DBForums.ForumThreadGetPosts(threadId)) { while (reader.Read()) { DataRow row = dataTable.NewRow(); row["PostID"] = reader["PostID"]; dataTable.Rows.Add(row); } } foreach (DataRow row in dataTable.Rows) { forumThread.DeletePost(Convert.ToInt32(row["PostID"])); } status = DBForums.ForumThreadDelete(threadId); return status; }