public List<ArticleComment> AllCommentByArticleId(string articleId)
        {
            SqlConnection connection = new SqlConnection(dbConnectionString);
            string query = "SELECT * FROM tbl_comment WHERE article_id = '"+articleId+"' ORDER BY id DESC";
            SqlCommand command = new SqlCommand(query, connection);
            connection.Open();

            SqlDataReader reader = command.ExecuteReader();

            List<ArticleComment> commentList = new List<ArticleComment>();

            while (reader.Read())
            {
                ArticleComment comment = new ArticleComment();
                comment.CommentArticleId = reader["id"].ToString();
                comment.CommentUserName = reader["user_name"].ToString();
                comment.CommentDescription = reader["comment_description"].ToString();
                comment.Date = reader["date"].ToString();
                commentList.Add(comment);
            }
            reader.Close();
            connection.Close();

            return commentList;
        }
 public void CommentArticle(ArticleComment articleComment)
 {
     SqlConnection connection = new SqlConnection(dbConnectionString);
     string query = "INSERT INTO tbl_comment(user_name,article_id,comment_description,date) VALUES ('" + articleComment.CommentUserName +
                    "','" +
                    articleComment.CommentArticleId + "','" + articleComment.CommentDescription + "','" + DateTime.Now + "')";
     SqlCommand command = new SqlCommand(query, connection);
     connection.Open();
     command.ExecuteNonQuery();
     connection.Close();
 }
        protected void detailPost_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            string articleID = Request.QueryString["articleId"];

            User aUser = (User)Session["user"];

            ArticleComment articleComment = new ArticleComment();
            articleComment.CommentUserName = aUser.UserName;
            articleComment.CommentDescription = Request.Form["commentDescription"];
            articleComment.CommentArticleId = articleID;

            commentManager.CommentArticle(articleComment);
        }
        protected void commentButton_Click(object sender, EventArgs e)
        {
            string articleID = Request.QueryString["articleId"];

            User aUser = (User)Session["user"];

            ArticleComment articleComment = new ArticleComment();
            articleComment.CommentUserName = aUser.UserName;
            articleComment.CommentDescription = Request.Form["commentDescription"];
            articleComment.CommentArticleId = articleID;

            commentManager.CommentArticle(articleComment);
        }
 public void CommentArticle(ArticleComment articleComment)
 {
     commentGateway.CommentArticle(articleComment);
 }