public IForumThreadDto GetForumThread(int threadID)
        {
            string         command = "SELECT * FROM thread WHERE ThreadID='{0}';";
            ForumThreadDto thread  = new ForumThreadDto();

            using (MySqlConnection conn = Connection.GetConnection())
            {
                conn.Open();
                MySqlCommand cmd = new MySqlCommand(string.Format(command, threadID.ToString()), conn);

                using MySqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    thread = new ForumThreadDto()
                    {
                        ThreadID          = Convert.ToInt32(reader["ThreadID"]),
                        AccountID         = Convert.ToInt32(reader["AccountID"]),
                        ForumCategoryID   = Convert.ToInt32(reader["ForumCategoryID"]),
                        ThreadTitle       = reader["ThreadTitle"].ToString(),
                        ThreadMessage     = reader["ThreadMessage"].ToString(),
                        ThreadDateCreated = Convert.ToDateTime(reader["ThreadDateCreated"])
                    };
                }
            }

            return(thread);
        }
Ejemplo n.º 2
0
        public int CreateForumThread(IForumThread forumThread)
        {
            IForumThreadDto forumThreadDto = new ForumThreadDto()
            {
                AccountID         = forumThread.AccountID,
                ForumCategoryID   = forumThread.ForumCategoryID,
                ThreadTitle       = forumThread.ThreadTitle,
                ThreadMessage     = forumThread.ThreadMessage,
                ThreadDateCreated = forumThread.ThreadDateCreated,
            };

            int rowcount = db.CreateThread(forumThreadDto);

            return(rowcount);
        }