private DBBlogComment GetBlogCommentFromReader(IDataReader dataReader) { DBBlogComment blogComment = new DBBlogComment(); blogComment.BlogCommentID = NopSqlDataHelper.GetInt(dataReader, "BlogCommentID"); blogComment.BlogPostID = NopSqlDataHelper.GetInt(dataReader, "BlogPostID"); blogComment.CustomerID = NopSqlDataHelper.GetInt(dataReader, "CustomerID"); blogComment.CommentText = NopSqlDataHelper.GetString(dataReader, "CommentText"); blogComment.CreatedOn = NopSqlDataHelper.GetUtcDateTime(dataReader, "CreatedOn"); return(blogComment); }
private DBBlogComment GetBlogCommentFromReader(IDataReader dataReader) { var item = new DBBlogComment(); item.BlogCommentId = NopSqlDataHelper.GetInt(dataReader, "BlogCommentID"); item.BlogPostId = NopSqlDataHelper.GetInt(dataReader, "BlogPostID"); item.CustomerId = NopSqlDataHelper.GetInt(dataReader, "CustomerID"); item.IPAddress = NopSqlDataHelper.GetString(dataReader, "IPAddress"); item.CommentText = NopSqlDataHelper.GetString(dataReader, "CommentText"); item.CreatedOn = NopSqlDataHelper.GetUtcDateTime(dataReader, "CreatedOn"); return(item); }
/// <summary> /// Gets an blog comment /// </summary> /// <param name="BlogCommentID">Blog comment identifier</param> /// <returns>An blog comment</returns> public override DBBlogComment GetBlogCommentByID(int BlogCommentID) { DBBlogComment blogComment = null; Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_BlogCommentLoadByPrimaryKey"); db.AddInParameter(dbCommand, "BlogCommentID", DbType.Int32, BlogCommentID); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { blogComment = GetBlogCommentFromReader(dataReader); } } return(blogComment); }
/// <summary> /// Gets all blog comments /// </summary> /// <returns>Blog comments</returns> public override DBBlogCommentCollection GetAllBlogComments() { DBBlogCommentCollection blogCommentCollection = new DBBlogCommentCollection(); Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_BlogCommentLoadAll"); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { DBBlogComment blogComment = GetBlogCommentFromReader(dataReader); blogCommentCollection.Add(blogComment); } } return(blogCommentCollection); }
/// <summary> /// Updates the blog comment /// </summary> /// <param name="BlogCommentID">The blog comment identifier</param> /// <param name="BlogPostID">The blog post identifier</param> /// <param name="CustomerID">The customer identifier who commented the blog post</param> /// <param name="CommentText">The comment text</param> /// <param name="CreatedOn">The date and time of instance creation</param> /// <returns>Blog comment</returns> public override DBBlogComment UpdateBlogComment(int BlogCommentID, int BlogPostID, int CustomerID, string CommentText, DateTime CreatedOn) { DBBlogComment blogComment = null; Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_BlogCommentUpdate"); db.AddInParameter(dbCommand, "BlogCommentID", DbType.Int32, BlogCommentID); db.AddInParameter(dbCommand, "BlogPostID", DbType.Int32, BlogPostID); db.AddInParameter(dbCommand, "CustomerID", DbType.Int32, CustomerID); db.AddInParameter(dbCommand, "CommentText", DbType.String, CommentText); db.AddInParameter(dbCommand, "CreatedOn", DbType.DateTime, CreatedOn); if (db.ExecuteNonQuery(dbCommand) > 0) { blogComment = GetBlogCommentByID(BlogCommentID); } return(blogComment); }
/// <summary> /// Updates the blog comment /// </summary> /// <param name="blogCommentId">The blog comment identifier</param> /// <param name="blogPostId">The blog post identifier</param> /// <param name="customerId">The customer identifier who commented the blog post</param> /// <param name="ipAddress">The IP address</param> /// <param name="commentText">The comment text</param> /// <param name="createdOn">The date and time of instance creation</param> /// <returns>Blog comment</returns> public override DBBlogComment UpdateBlogComment(int blogCommentId, int blogPostId, int customerId, string ipAddress, string commentText, DateTime createdOn) { DBBlogComment item = null; Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_BlogCommentUpdate"); db.AddInParameter(dbCommand, "BlogCommentID", DbType.Int32, blogCommentId); db.AddInParameter(dbCommand, "BlogPostID", DbType.Int32, blogPostId); db.AddInParameter(dbCommand, "CustomerID", DbType.Int32, customerId); db.AddInParameter(dbCommand, "IPAddress", DbType.String, ipAddress); db.AddInParameter(dbCommand, "CommentText", DbType.String, commentText); db.AddInParameter(dbCommand, "CreatedOn", DbType.DateTime, createdOn); if (db.ExecuteNonQuery(dbCommand) > 0) { item = GetBlogCommentById(blogCommentId); } return(item); }
/// <summary> /// Gets a collection of blog comments by blog post identifier /// </summary> /// <param name="BlogPostID">Blog post identifier</param> /// <returns>A collection of blog comments</returns> public override DBBlogCommentCollection GetBlogCommentsByBlogPostID(int BlogPostID) { DBBlogCommentCollection blogCommentCollection = new DBBlogCommentCollection(); if (BlogPostID == 0) { return(blogCommentCollection); } Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_BlogCommentLoadByBlogPostID"); db.AddInParameter(dbCommand, "BlogPostID", DbType.Int32, BlogPostID); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { DBBlogComment blogComment = GetBlogCommentFromReader(dataReader); blogCommentCollection.Add(blogComment); } } return(blogCommentCollection); }