private DBNewsComment GetNewsCommentFromReader(IDataReader dataReader)
        {
            DBNewsComment newsComment = new DBNewsComment();

            newsComment.NewsCommentID = NopSqlDataHelper.GetInt(dataReader, "NewsCommentID");
            newsComment.NewsID        = NopSqlDataHelper.GetInt(dataReader, "NewsID");
            newsComment.CustomerID    = NopSqlDataHelper.GetInt(dataReader, "CustomerID");
            newsComment.Title         = NopSqlDataHelper.GetString(dataReader, "Title");
            newsComment.Comment       = NopSqlDataHelper.GetString(dataReader, "Comment");
            newsComment.CreatedOn     = NopSqlDataHelper.GetUtcDateTime(dataReader, "CreatedOn");
            return(newsComment);
        }
Beispiel #2
0
        private DBNewsComment GetNewsCommentFromReader(IDataReader dataReader)
        {
            var item = new DBNewsComment();

            item.NewsCommentId = NopSqlDataHelper.GetInt(dataReader, "NewsCommentID");
            item.NewsId        = NopSqlDataHelper.GetInt(dataReader, "NewsID");
            item.CustomerId    = NopSqlDataHelper.GetInt(dataReader, "CustomerID");
            item.IPAddress     = NopSqlDataHelper.GetString(dataReader, "IPAddress");
            item.Title         = NopSqlDataHelper.GetString(dataReader, "Title");
            item.Comment       = NopSqlDataHelper.GetString(dataReader, "Comment");
            item.CreatedOn     = NopSqlDataHelper.GetUtcDateTime(dataReader, "CreatedOn");
            return(item);
        }
Beispiel #3
0
        /// <summary>
        /// Gets a news comment
        /// </summary>
        /// <param name="newsCommentId">News comment identifer</param>
        /// <returns>News comment</returns>
        public override DBNewsComment GetNewsCommentById(int newsCommentId)
        {
            DBNewsComment item      = null;
            Database      db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand     dbCommand = db.GetStoredProcCommand("Nop_NewsCommentLoadByPrimaryKey");

            db.AddInParameter(dbCommand, "NewsCommentID", DbType.Int32, newsCommentId);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    item = GetNewsCommentFromReader(dataReader);
                }
            }
            return(item);
        }
        /// <summary>
        /// Gets all news comments
        /// </summary>
        /// <returns>News comment collection</returns>
        public override DBNewsCommentCollection GetAllNewsComments()
        {
            DBNewsCommentCollection newsCommentCollection = new DBNewsCommentCollection();
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_NewsCommentLoadAll");

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    DBNewsComment newsComment = GetNewsCommentFromReader(dataReader);
                    newsCommentCollection.Add(newsComment);
                }
            }

            return(newsCommentCollection);
        }
        /// <summary>
        /// Gets a news comment collection by news identifier
        /// </summary>
        /// <param name="NewsID">The news identifier</param>
        /// <returns>News comment collection</returns>
        public override DBNewsCommentCollection GetNewsCommentsByNewsID(int NewsID)
        {
            DBNewsCommentCollection newsCommentCollection = new DBNewsCommentCollection();
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_NewsCommentLoadByNewsID");

            db.AddInParameter(dbCommand, "NewsID", DbType.Int32, NewsID);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    DBNewsComment newsComment = GetNewsCommentFromReader(dataReader);
                    newsCommentCollection.Add(newsComment);
                }
            }
            return(newsCommentCollection);
        }
        /// <summary>
        /// Inserts a news comment
        /// </summary>
        /// <param name="NewsID">The news identifier</param>
        /// <param name="CustomerID">The customer identifier</param>
        /// <param name="Title">The title</param>
        /// <param name="Comment">The comment</param>
        /// <param name="CreatedOn">The date and time of instance creation</param>
        /// <returns>News comment</returns>
        public override DBNewsComment InsertNewsComment(int NewsID, int CustomerID, string Title,
                                                        string Comment, DateTime CreatedOn)
        {
            DBNewsComment newsComment = null;
            Database      db          = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand     dbCommand   = db.GetStoredProcCommand("Nop_NewsCommentInsert");

            db.AddOutParameter(dbCommand, "NewsCommentID", DbType.Int32, 0);
            db.AddInParameter(dbCommand, "NewsID", DbType.Int32, NewsID);
            db.AddInParameter(dbCommand, "CustomerID", DbType.Int32, CustomerID);
            db.AddInParameter(dbCommand, "Title", DbType.String, Title);
            db.AddInParameter(dbCommand, "Comment", DbType.String, Comment);
            db.AddInParameter(dbCommand, "CreatedOn", DbType.DateTime, CreatedOn);
            if (db.ExecuteNonQuery(dbCommand) > 0)
            {
                int NewsCommentID = Convert.ToInt32(db.GetParameterValue(dbCommand, "@NewsCommentID"));
                newsComment = GetNewsCommentByID(NewsCommentID);
            }
            return(newsComment);
        }
Beispiel #7
0
        /// <summary>
        /// Inserts a news comment
        /// </summary>
        /// <param name="newsId">The news identifier</param>
        /// <param name="customerId">The customer identifier</param>
        /// <param name="ipAddress">The IP address</param>
        /// <param name="title">The title</param>
        /// <param name="comment">The comment</param>
        /// <param name="createdOn">The date and time of instance creation</param>
        /// <returns>News comment</returns>
        public override DBNewsComment InsertNewsComment(int newsId, int customerId, string ipAddress,
                                                        string title, string comment, DateTime createdOn)
        {
            DBNewsComment item      = null;
            Database      db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand     dbCommand = db.GetStoredProcCommand("Nop_NewsCommentInsert");

            db.AddOutParameter(dbCommand, "NewsCommentID", DbType.Int32, 0);
            db.AddInParameter(dbCommand, "NewsID", DbType.Int32, newsId);
            db.AddInParameter(dbCommand, "CustomerID", DbType.Int32, customerId);
            db.AddInParameter(dbCommand, "IPAddress", DbType.String, ipAddress);
            db.AddInParameter(dbCommand, "Title", DbType.String, title);
            db.AddInParameter(dbCommand, "Comment", DbType.String, comment);
            db.AddInParameter(dbCommand, "CreatedOn", DbType.DateTime, createdOn);
            if (db.ExecuteNonQuery(dbCommand) > 0)
            {
                int newsCommentId = Convert.ToInt32(db.GetParameterValue(dbCommand, "@NewsCommentID"));
                item = GetNewsCommentById(newsCommentId);
            }
            return(item);
        }