예제 #1
0
        private void bindBlogPosts(BlogPost[] blogPosts)
        {
            dgPendingApproval.Columns[0].HeaderText = Lang.TransA("Username");
            dgPendingApproval.Columns[1].HeaderText = Lang.TransA("Title");
            dgPendingApproval.Columns[2].HeaderText = Lang.TransA("Content");

            DataTable dtAnswers = new DataTable("BlogPosts");
            dtAnswers.Columns.Add("ID");
            dtAnswers.Columns.Add("Username");
            dtAnswers.Columns.Add("Title");
            dtAnswers.Columns.Add("Content");
            dtAnswers.Columns.Add("DatePosted");

            foreach (BlogPost blogPost in blogPosts)
            {
                Blog blog = Blog.Load(blogPost.BlogId);
                if (blog == null) continue;

                dtAnswers.Rows.Add(new object[]
                                       {
                                           blogPost.Id,
                                           blog.Username,
                                           blogPost.Title,
                                           blogPost.Content.Length > 300
                                               ? Server.HtmlEncode(blogPost.Content.Substring(0, 300)) + "..."
                                               : Server.HtmlEncode(blogPost.Content),
                                           blogPost.DatePosted
                                       }
                    );
            }

            dgPendingApproval.DataSource = dtAnswers;
            try
            {
                dgPendingApproval.DataBind();
            }
            catch (HttpException)
            {
                dgPendingApproval.CurrentPageIndex = 0;
                dgPendingApproval.DataBind();
            }
        }
예제 #2
0
파일: Blogs.cs 프로젝트: varlo/Unona9
        private static BlogPost[] Fetch(int blogId, int blogPostId, bool? approved)
        {
            List<BlogPost> lBlogPosts = new List<BlogPost>();

            using (SqlConnection conn = Config.DB.Open())
            {
                SqlDataReader reader = SqlHelper.ExecuteReader(conn, "FetchBlogPosts", blogId, blogPostId, approved);

                while (reader.Read())
                {
                    BlogPost blogPost = new BlogPost();

                    blogPost.id = (int) reader["Id"];
                    blogPost.blogId = (int) reader["BlogId"];
                    blogPost.title = (string) reader["Title"];
                    blogPost.content = (string) reader["Content"];
                    blogPost.datePosted = (DateTime) reader["DatePosted"];
                    blogPost.reads = (int) reader["Reads"];
                    blogPost.approved = (bool) reader["Approved"];

                    lBlogPosts.Add(blogPost);
                }
            }

            return lBlogPosts.ToArray();
        }
예제 #3
0
파일: Blogs.cs 프로젝트: varlo/Unona9
 public static BlogPost Create(int blogId, string title, string content)
 {
     BlogPost blogPost = new BlogPost();
     blogPost.id = -1;
     blogPost.blogId = blogId;
     blogPost.title = title;
     blogPost.content = content;
     blogPost.datePosted = DateTime.Now;
     blogPost.reads = 0;
     return blogPost;
 }
예제 #4
0
 private void LoadBlogPost(BlogPost blogPost)
 {
     lblDate.Text = blogPost.DatePosted.ToLongDateString();
     lblTitle.Text = Server.HtmlEncode(blogPost.Title);
     lblContent.Text = stripDangerousHtml(blogPost.Content);
     lblDirectLink.Text = UrlRewrite.CreateShowUserBlogUrl(CurrentBlog.Username, BlogPostId);
     divViewPost.Visible = true;
     divViewBlog.Visible = false;
 }