public static List<Post> GetPostsByThreadId(int thread_id) { DataTable table = ForumDB.QuerySproc("GetPostsByThreadId", new SqlParameter("thread_id", thread_id)); List<Post> results = new List<Post>(); for (int i = 0; i < table.Rows.Count; i++) { Post result = new Post { post_id = table.Rows[i].ToInt32("post_id"), thread_id = table.Rows[i].ToInt32("thread_id"), subject = table.Rows[i].ToString("subject"), content = table.Rows[i].ToString("content"), post_date = table.Rows[i].ToDateTime("post_date"), reply_to = table.Rows[i].ToNullableInt32("reply_to"), user = new User { UserId = table.Rows[i].ToInt32("user_id"), Username = table.Rows[i].ToString("username") } }; results.Add(result); } return results; }
public void AddPost(Post post) { int post_id = (int)ForumDB.ExecuteScalar("ReplyToPost", new SqlParameter("thread_id", this.thread_id), new SqlParameter("user_id", post.user.UserId), new SqlParameter("content", post.content), new SqlParameter("reply_to", post.reply_to)); post.post_id = post_id; }