예제 #1
0
        public static BlogPostComment[] Fetch(int id, int blogPostId, string username, bool approveFilter,
                                              bool approved)
        {
            List<BlogPostComment> lComments = new List<BlogPostComment>();

            //using (var conn = Config.DB.Open())
            {
                //HACK approveFilter = false
                approveFilter = false;

                using (var reader = SqlHelper.GetDB().ExecuteReader("FetchBlogPostComments",
                                              id, blogPostId, username,approveFilter ? (object) approved : null))
                {
                    while (reader.Read())
                    {
                        BlogPostComment blogPostComment = new BlogPostComment();

                        blogPostComment.id = (int) reader["Id"];
                        blogPostComment.blogPostId = (int) reader["BlogPostId"];
                        blogPostComment.username = (string) reader["Username"];
                        blogPostComment.commentText = (string) reader["CommentText"];
                        blogPostComment.datePosted = (DateTime) reader["DatePosted"];
                        blogPostComment.approved = (bool) reader["Approved"];

                        lComments.Add(blogPostComment);
                    }
                    reader.Close();
                }
            }

            return lComments.ToArray();
        }
예제 #2
0
 public static BlogPostComment Create(int blogPostId, string username, string commentText)
 {
     BlogPostComment blogPostComment = new BlogPostComment();
     blogPostComment.id = -1;
     blogPostComment.blogPostId = blogPostId;
     blogPostComment.username = username;
     blogPostComment.commentText = commentText;
     blogPostComment.datePosted = DateTime.Now;
     blogPostComment.approved = true;
     return blogPostComment;
 }