Ejemplo n.º 1
0
        private DBSetting GetSettingFromReader(IDataReader dataReader)
        {
            DBSetting setting = new DBSetting();

            setting.SettingID   = NopSqlDataHelper.GetInt(dataReader, "SettingID");
            setting.Name        = NopSqlDataHelper.GetString(dataReader, "Name");
            setting.Value       = NopSqlDataHelper.GetString(dataReader, "Value");
            setting.Description = NopSqlDataHelper.GetString(dataReader, "Description");
            return(setting);
        }
Ejemplo n.º 2
0
        private DBSetting GetSettingFromReader(IDataReader dataReader)
        {
            var item = new DBSetting();

            item.SettingId   = NopSqlDataHelper.GetInt(dataReader, "SettingID");
            item.Name        = NopSqlDataHelper.GetString(dataReader, "Name");
            item.Value       = NopSqlDataHelper.GetString(dataReader, "Value");
            item.Description = NopSqlDataHelper.GetString(dataReader, "Description");
            return(item);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets all settings
        /// </summary>
        /// <returns>Setting collection</returns>
        public override DBSettingCollection GetAllSettings()
        {
            DBSettingCollection settingCollection = new DBSettingCollection();
            Database            db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand           dbCommand = db.GetStoredProcCommand("Nop_SettingLoadAll");

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    DBSetting setting = GetSettingFromReader(dataReader);
                    settingCollection.Add(setting);
                }
            }
            return(settingCollection);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets a setting
        /// </summary>
        /// <param name="SettingID">Setting identifer</param>
        /// <returns>Setting</returns>
        public override DBSetting GetSettingByID(int SettingID)
        {
            DBSetting setting   = null;
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_SettingLoadByPrimaryKey");

            db.AddInParameter(dbCommand, "SettingID", DbType.Int32, SettingID);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    setting = GetSettingFromReader(dataReader);
                }
            }

            return(setting);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Updates a setting
        /// </summary>
        /// <param name="SettingID">Setting identifier</param>
        /// <param name="Name">The name</param>
        /// <param name="Value">The value</param>
        /// <param name="Description">The description</param>
        /// <returns>Setting</returns>
        public override DBSetting UpdateSetting(int SettingID, string Name, string Value, string Description)
        {
            DBSetting setting   = null;
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_SettingUpdate");

            db.AddInParameter(dbCommand, "SettingID", DbType.Int32, SettingID);
            db.AddInParameter(dbCommand, "Name", DbType.String, Name);
            db.AddInParameter(dbCommand, "Value", DbType.String, Value);
            db.AddInParameter(dbCommand, "Description", DbType.String, Description);
            if (db.ExecuteNonQuery(dbCommand) > 0)
            {
                setting = GetSettingByID(SettingID);
            }

            return(setting);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Adds a setting
        /// </summary>
        /// <param name="name">The name</param>
        /// <param name="value">The value</param>
        /// <param name="description">The description</param>
        /// <returns>Setting</returns>
        public override DBSetting AddSetting(string name, string value, string description)
        {
            DBSetting item      = null;
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_SettingInsert");

            db.AddOutParameter(dbCommand, "SettingID", DbType.Int32, 0);
            db.AddInParameter(dbCommand, "Name", DbType.String, name);
            db.AddInParameter(dbCommand, "Value", DbType.String, value);
            db.AddInParameter(dbCommand, "Description", DbType.String, description);
            if (db.ExecuteNonQuery(dbCommand) > 0)
            {
                int settingId = Convert.ToInt32(db.GetParameterValue(dbCommand, "@SettingID"));
                item = GetSettingById(settingId);
            }
            return(item);
        }