コード例 #1
0
        private DBTopic GetTopicFromReader(IDataReader dataReader)
        {
            var item = new DBTopic();

            item.TopicId = NopSqlDataHelper.GetInt(dataReader, "TopicID");
            item.Name    = NopSqlDataHelper.GetString(dataReader, "Name");
            return(item);
        }
コード例 #2
0
        private DBTopic GetTopicFromReader(IDataReader dataReader)
        {
            DBTopic topic = new DBTopic();

            topic.TopicID         = NopSqlDataHelper.GetInt(dataReader, "TopicID");
            topic.Name            = NopSqlDataHelper.GetString(dataReader, "Name");
            topic.MetaDescription = NopSqlDataHelper.GetString(dataReader, "MetaDescription");
            topic.MetaKeywords    = NopSqlDataHelper.GetString(dataReader, "MetaKeywords");
            topic.MetaTitle       = NopSqlDataHelper.GetString(dataReader, "MetaTitle");
            return(topic);
        }
コード例 #3
0
        private static Topic DBMapping(DBTopic dbItem)
        {
            if (dbItem == null)
                return null;

            Topic item = new Topic();
            item.TopicID = dbItem.TopicID;
            item.Name = dbItem.Name;
            item.MetaDescription = dbItem.MetaDescription;
            item.MetaKeywords = dbItem.MetaKeywords;
            item.MetaTitle = dbItem.MetaTitle;

            return item;
        }
コード例 #4
0
        /// <summary>
        /// Updates the topic
        /// </summary>
        /// <param name="topicId">The topic identifier</param>
        /// <param name="name">The name</param>
        /// <returns>Topic</returns>
        public override DBTopic UpdateTopic(int topicId, string name)
        {
            DBTopic   item      = null;
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_TopicUpdate");

            db.AddInParameter(dbCommand, "TopicID", DbType.Int32, topicId);
            db.AddInParameter(dbCommand, "Name", DbType.String, name);
            if (db.ExecuteNonQuery(dbCommand) > 0)
            {
                item = GetTopicById(topicId);
            }

            return(item);
        }
コード例 #5
0
        /// <summary>
        /// Inserts a topic
        /// </summary>
        /// <param name="name">The name</param>
        /// <returns>Topic</returns>
        public override DBTopic InsertTopic(string name)
        {
            DBTopic   item      = null;
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_TopicInsert");

            db.AddOutParameter(dbCommand, "TopicID", DbType.Int32, 0);
            db.AddInParameter(dbCommand, "Name", DbType.String, name);
            if (db.ExecuteNonQuery(dbCommand) > 0)
            {
                int topicId = Convert.ToInt32(db.GetParameterValue(dbCommand, "@TopicID"));
                item = GetTopicById(topicId);
            }
            return(item);
        }
コード例 #6
0
        /// <summary>
        /// Gets all topics
        /// </summary>
        /// <returns>Topic collection</returns>
        public override DBTopicCollection GetAllTopics()
        {
            DBTopicCollection topicCollection = new DBTopicCollection();
            Database          db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand         dbCommand = db.GetStoredProcCommand("Nop_TopicLoadAll");

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    DBTopic topic = GetTopicFromReader(dataReader);
                    topicCollection.Add(topic);
                }
            }
            return(topicCollection);
        }
コード例 #7
0
        /// <summary>
        /// Inserts a topic
        /// </summary>
        /// <param name="Name">The name</param>
        /// <param name="metaKeywords">Key words adds to title (SEO)</param>
        /// <param name="metaDescription">Description for SEO</param>
        /// <param name="metaTitle">Title for SEO</param>
        /// <returns>Topic</returns>
        public override DBTopic InsertTopic(string Name, string metaKeywords, string metaDescription, string metaTitle)
        {
            DBTopic   topic     = null;
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_TopicInsert");

            db.AddOutParameter(dbCommand, "TopicID", DbType.Int32, 0);
            db.AddInParameter(dbCommand, "Name", DbType.String, Name);
            db.AddInParameter(dbCommand, "MetaKeywords", DbType.String, metaKeywords);
            db.AddInParameter(dbCommand, "MetaDescription", DbType.String, metaDescription);
            db.AddInParameter(dbCommand, "MetaTitle", DbType.String, metaTitle);
            if (db.ExecuteNonQuery(dbCommand) > 0)
            {
                int TopicID = Convert.ToInt32(db.GetParameterValue(dbCommand, "@TopicID"));
                topic = GetTopicByID(TopicID);
            }
            return(topic);
        }
コード例 #8
0
        /// <summary>
        /// Gets a topic by template identifier
        /// </summary>
        /// <param name="topicId">Topic identifier</param>
        /// <returns>Topic</returns>
        public override DBTopic GetTopicById(int topicId)
        {
            DBTopic item = null;

            if (topicId == 0)
            {
                return(item);
            }
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_TopicLoadByPrimaryKey");

            db.AddInParameter(dbCommand, "TopicID", DbType.Int32, topicId);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    item = GetTopicFromReader(dataReader);
                }
            }
            return(item);
        }