Ejemplo n.º 1
0
        private DBBlogPost GetBlogPostFromReader(IDataReader dataReader)
        {
            DBBlogPost blogPost = new DBBlogPost();

            blogPost.BlogPostID            = NopSqlDataHelper.GetInt(dataReader, "BlogPostID");
            blogPost.LanguageID            = NopSqlDataHelper.GetInt(dataReader, "LanguageID");
            blogPost.BlogPostTitle         = NopSqlDataHelper.GetString(dataReader, "BlogPostTitle");
            blogPost.BlogPostBody          = NopSqlDataHelper.GetString(dataReader, "BlogPostBody");
            blogPost.BlogPostAllowComments = NopSqlDataHelper.GetBoolean(dataReader, "BlogPostAllowComments");
            blogPost.CreatedByID           = NopSqlDataHelper.GetInt(dataReader, "CreatedByID");
            blogPost.CreatedOn             = NopSqlDataHelper.GetUtcDateTime(dataReader, "CreatedOn");
            return(blogPost);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets an blog post
        /// </summary>
        /// <param name="BlogPostID">Blog post identifier</param>
        /// <returns>Blog post</returns>
        public override DBBlogPost GetBlogPostByID(int BlogPostID)
        {
            DBBlogPost blogPost  = null;
            Database   db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand  dbCommand = db.GetStoredProcCommand("Nop_BlogPostLoadByPrimaryKey");

            db.AddInParameter(dbCommand, "BlogPostID", DbType.Int32, BlogPostID);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    blogPost = GetBlogPostFromReader(dataReader);
                }
            }
            return(blogPost);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets all blog posts
        /// </summary>
        /// <param name="LanguageID">Language identifier. 0 if you want to get all news</param>
        /// <returns>Blog posts</returns>
        public override DBBlogPostCollection GetAllBlogPosts(int LanguageID)
        {
            DBBlogPostCollection blogPostCollection = new DBBlogPostCollection();
            Database             db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand            dbCommand = db.GetStoredProcCommand("Nop_BlogPostLoadAll");

            db.AddInParameter(dbCommand, "LanguageID", DbType.Int32, LanguageID);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    DBBlogPost blogPost = GetBlogPostFromReader(dataReader);
                    blogPostCollection.Add(blogPost);
                }
            }

            return(blogPostCollection);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Updates the blog post
        /// </summary>
        /// <param name="LanguageID">The language identifier</param>
        /// <param name="BlogPostID">Blog post identifier</param>
        /// <param name="BlogPostTitle">The blog post title</param>
        /// <param name="BlogPostBody">The blog post title</param>
        /// <param name="BlogPostAllowComments">A value indicating whether the blog post comments are allowed</param>
        /// <param name="CreatedByID">The user identifier who created the blog post</param>
        /// <param name="CreatedOn">The date and time of instance creation</param>
        /// <returns>Blog post</returns>
        public override DBBlogPost UpdateBlogPost(int BlogPostID, int LanguageID, string BlogPostTitle, string BlogPostBody,
                                                  bool BlogPostAllowComments, int CreatedByID, DateTime CreatedOn)
        {
            DBBlogPost blogPost  = null;
            Database   db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand  dbCommand = db.GetStoredProcCommand("Nop_BlogPostUpdate");

            db.AddInParameter(dbCommand, "BlogPostID", DbType.Int32, BlogPostID);
            db.AddInParameter(dbCommand, "LanguageID", DbType.Int32, LanguageID);
            db.AddInParameter(dbCommand, "BlogPostTitle", DbType.String, BlogPostTitle);
            db.AddInParameter(dbCommand, "BlogPostBody", DbType.String, BlogPostBody);
            db.AddInParameter(dbCommand, "BlogPostAllowComments", DbType.Boolean, BlogPostAllowComments);
            db.AddInParameter(dbCommand, "CreatedByID", DbType.Int32, CreatedByID);
            db.AddInParameter(dbCommand, "CreatedOn", DbType.DateTime, CreatedOn);
            if (db.ExecuteNonQuery(dbCommand) > 0)
            {
                blogPost = GetBlogPostByID(BlogPostID);
            }

            return(blogPost);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Inserts an blog post
        /// </summary>
        /// <param name="languageId">The language identifier</param>
        /// <param name="blogPostTitle">The blog post title</param>
        /// <param name="blogPostBody">The blog post title</param>
        /// <param name="blogPostAllowComments">A value indicating whether the blog post comments are allowed</param>
        /// <param name="createdById">The user identifier who created the blog post</param>
        /// <param name="createdOn">The date and time of instance creation</param>
        /// <returns>Blog post</returns>
        public override DBBlogPost InsertBlogPost(int languageId, string blogPostTitle,
                                                  string blogPostBody, bool blogPostAllowComments,
                                                  int createdById, DateTime createdOn)
        {
            DBBlogPost item      = null;
            Database   db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand  dbCommand = db.GetStoredProcCommand("Nop_BlogPostInsert");

            db.AddOutParameter(dbCommand, "BlogPostID", DbType.Int32, 0);
            db.AddInParameter(dbCommand, "LanguageID", DbType.Int32, languageId);
            db.AddInParameter(dbCommand, "BlogPostTitle", DbType.String, blogPostTitle);
            db.AddInParameter(dbCommand, "BlogPostBody", DbType.String, blogPostBody);
            db.AddInParameter(dbCommand, "BlogPostAllowComments", DbType.Boolean, blogPostAllowComments);
            db.AddInParameter(dbCommand, "CreatedByID", DbType.Int32, createdById);
            db.AddInParameter(dbCommand, "CreatedOn", DbType.DateTime, createdOn);
            if (db.ExecuteNonQuery(dbCommand) > 0)
            {
                int blogPostId = Convert.ToInt32(db.GetParameterValue(dbCommand, "@BlogPostID"));
                item = GetBlogPostById(blogPostId);
            }
            return(item);
        }