Exemplo n.º 1
0
        public Collection <Comment> GetAllComments(CommentType ctype)
        {
            using (SqlConnection connection = this.GetConnection())
            {
                connection.Open();

                SqlCommand sc = new SqlCommand("GetAllComments", connection);
                sc.CommandType = CommandType.StoredProcedure;

                Collection <Comment> clist = SqlDataMap.CreateCommentsFromReader(sc.ExecuteReader());

                return(clist);
            }
        }
Exemplo n.º 2
0
        public Collection <Comment> GetCommentsForPost(int postId, CommentType ctype)
        {
            using (SqlConnection connection = this.GetConnection())
            {
                connection.Open();

                SqlCommand sc = new SqlCommand("GetCommentsByPost", connection);
                sc.CommandType = CommandType.StoredProcedure;

                sc.Parameters.AddWithValue("PostId", postId);

                if (ctype == CommentType.All)
                {
                    sc.Parameters.AddWithValue("Approved", DBNull.Value);
                }
                else
                {
                    int bitValue = 0;

                    if (ctype == CommentType.Approved)
                    {
                        bitValue = 1;
                    }
                    else if (ctype == CommentType.UnApproved)
                    {
                        bitValue = 0;
                    }

                    sc.Parameters.AddWithValue("Approved", bitValue);
                }

                Collection <Comment> clist = SqlDataMap.CreateCommentsFromReader(sc.ExecuteReader());

                return(clist);
            }
        }