コード例 #1
0
ファイル: Blogs.cs プロジェクト: varlo/Unona9
        public static BlogPostComment[] Fetch(int id, int blogPostId, string username, bool approveFilter,
            bool approved)
        {
            List<BlogPostComment> lComments = new List<BlogPostComment>();

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

                SqlDataReader reader = SqlHelper.ExecuteReader(conn, "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);
                }
            }

            return lComments.ToArray();
        }
コード例 #2
0
ファイル: Blogs.cs プロジェクト: varlo/Unona9
 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;
 }