コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: EditPost.aspx.cs プロジェクト: saiesh86/TravelBlog
        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());
        }
コード例 #3
0
ファイル: ForumThread.cs プロジェクト: joedavis01/mojoportal
        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;
        }