Пример #1
0
        /// <summary>
        /// Gives the most recent version of the given thread
        /// </summary>
        /// <param name="id">id is used to identify the thread</param>
        /// <returns>the most recent version of the thread</returns>
        public static ForumThread UpdateThread(int id)
        {
            OracleConnection conn = MakeConnection();
            conn.Open();

            string mainQuery = "SELECT * FROM THREAD WHERE THREADID = :THREADID";

            OracleCommand command = new OracleCommand(mainQuery, conn);
            command.Parameters.Add(new OracleParameter("THREADID", id));
            OracleDataReader dataReaderThread;
            OracleDataReader dataReaderPosts;

            ForumThread thread = null;

            try
            {
                dataReaderThread = command.ExecuteReader();
                while (dataReaderThread.Read())
                {
                    List<Post> posts = new List<Post>();
                    string postQuery = "SELECT * FROM POST WHERE THREADID =" + dataReaderThread["threadID"];
                    OracleCommand threadCommand = new OracleCommand(postQuery, conn);

                    dataReaderPosts = threadCommand.ExecuteReader();
                    while (dataReaderPosts.Read())
                    {
                        posts.Add(new Post(Convert.ToInt32(dataReaderPosts["postID"].ToString()), dataReaderPosts["inhoud"].ToString(), dataReaderPosts["USERNAME"].ToString()));
                    }

                    ForumCategory category = MainAdministration.Categorys.Find(x => x.ID == Convert.ToInt32(dataReaderThread["FORUMCATEGORIEID"].ToString()));

                    thread = new ForumThread(Convert.ToInt32(dataReaderThread["threadID"].ToString()), posts, category, dataReaderThread["THREADNAME"].ToString(), dataReaderThread["USERNAME"].ToString());
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }

            return thread;
        }
Пример #2
0
 /// <summary>
 /// create a new post
 /// </summary>
 /// <param name="user">User that posted this post</param>
 /// <param name="content">Content of this post</param>
 /// <param name="thread">thread this post belongs to</param>
 public static void CreateNewPost(User user, string content, ForumThread thread)
 {
     DatabaseManager.CreateNewPost(thread.ID, content, user.Username);
 }
Пример #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         currentThread = MainAdministration.UpdateThread(((ForumThread)Session["NextPage"]).ID);
         postCounter = Convert.ToInt32(Session["COUNTER"]);
         Pageinitialization();
     }
     catch (Exception)
     {
         Page.Response.Redirect("Default.aspx");
         Session["PreviousPage"] = null;
         Session["NextPage"] = "Main";
     }
 }
Пример #4
0
 /// <summary>
 /// Deletes a thread
 /// </summary>
 /// <param name="thread">thread that needs to be deleted</param>
 public static void DeleteThread(ForumThread thread)
 {
     DatabaseManager.DeleteThread(thread.ID);
 }