/// <summary>
        /// Gets specification attribute option collection
        /// </summary>
        /// <param name="specificationAttributeID">Specification attribute unique identifier</param>
        /// <returns>Specification attribute option collection</returns>
        public override DBSpecificationAttributeOptionCollection GetSpecificationAttributeOptionsBySpecificationAttributeID(int specificationAttributeID)
        {
            DBSpecificationAttributeOptionCollection saoCol = new DBSpecificationAttributeOptionCollection();

            if (specificationAttributeID == 0)
            {
                return(saoCol);
            }

            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_SpecificationAttributeOptionLoadBySpecificationAttributeID");

            db.AddInParameter(dbCommand, "SpecificationAttributeID", DbType.Int32, specificationAttributeID);

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    DBSpecificationAttributeOption sao = GetSpecificationAttributeOptionFromReader(dataReader);
                    saoCol.Add(sao);
                }
            }

            return(saoCol);
        }
 /// <summary>
 /// Maps a data reader to a specification attribute option
 /// </summary>
 /// <param name="dataReader">IDataReader</param>
 /// <returns>Specification attribute option</returns>
 private DBSpecificationAttributeOption GetSpecificationAttributeOptionFromReader(IDataReader dataReader)
 {
     DBSpecificationAttributeOption specificationAttributeOption = new DBSpecificationAttributeOption();
     specificationAttributeOption.SpecificationAttributeOptionID = NopSqlDataHelper.GetInt(dataReader, "SpecificationAttributeOptionID");
     specificationAttributeOption.SpecificationAttributeID = NopSqlDataHelper.GetInt(dataReader, "SpecificationAttributeID");
     specificationAttributeOption.Name = NopSqlDataHelper.GetString(dataReader, "Name");
     specificationAttributeOption.DisplayOrder = NopSqlDataHelper.GetInt(dataReader, "DisplayOrder");
     return specificationAttributeOption;
 }
        /// <summary>
        /// Maps a data reader to a specification attribute option
        /// </summary>
        /// <param name="dataReader">IDataReader</param>
        /// <returns>Specification attribute option</returns>
        private DBSpecificationAttributeOption GetSpecificationAttributeOptionFromReader(IDataReader dataReader)
        {
            var item = new DBSpecificationAttributeOption();

            item.SpecificationAttributeOptionId = NopSqlDataHelper.GetInt(dataReader, "SpecificationAttributeOptionID");
            item.SpecificationAttributeId       = NopSqlDataHelper.GetInt(dataReader, "SpecificationAttributeID");
            item.Name         = NopSqlDataHelper.GetString(dataReader, "Name");
            item.DisplayOrder = NopSqlDataHelper.GetInt(dataReader, "DisplayOrder");
            return(item);
        }
        /// <summary>
        /// Maps a data reader to a specification attribute option
        /// </summary>
        /// <param name="dataReader">IDataReader</param>
        /// <returns>Specification attribute option</returns>
        private DBSpecificationAttributeOption GetSpecificationAttributeOptionFromReader(IDataReader dataReader)
        {
            DBSpecificationAttributeOption specificationAttributeOption = new DBSpecificationAttributeOption();

            specificationAttributeOption.SpecificationAttributeOptionID = NopSqlDataHelper.GetInt(dataReader, "SpecificationAttributeOptionID");
            specificationAttributeOption.SpecificationAttributeID       = NopSqlDataHelper.GetInt(dataReader, "SpecificationAttributeID");
            specificationAttributeOption.Name         = NopSqlDataHelper.GetString(dataReader, "Name");
            specificationAttributeOption.DisplayOrder = NopSqlDataHelper.GetInt(dataReader, "DisplayOrder");
            return(specificationAttributeOption);
        }
        /// <summary>
        /// Gets a specification attribute option collection
        /// </summary>
        /// <returns>Specification attribute option collection</returns>
        public override DBSpecificationAttributeOptionCollection GetSpecificationAttributeOptions()
        {
            DBSpecificationAttributeOptionCollection saoCol = new DBSpecificationAttributeOptionCollection();
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_SpecificationAttributeOptionLoadAll");

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    DBSpecificationAttributeOption sao = GetSpecificationAttributeOptionFromReader(dataReader);
                    saoCol.Add(sao);
                }
            }

            return(saoCol);
        }
        /// <summary>
        /// Updates the specification attribute option
        /// </summary>
        /// <param name="specificationAttributeOptionId">The specification attribute option identifier</param>
        /// <param name="specificationAttributeId">The specification attribute identifier</param>
        /// <param name="name">The name</param>
        /// <param name="displayOrder">Display order</param>
        /// <returns>Specification attribute option</returns>
        public override DBSpecificationAttributeOption UpdateSpecificationAttributeOption(int specificationAttributeOptionId,
                                                                                          int specificationAttributeId, string name, int displayOrder)
        {
            DBSpecificationAttributeOption item = null;
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_SpecificationAttributeOptionUpdate");

            db.AddInParameter(dbCommand, "SpecificationAttributeOptionID", DbType.Int32, specificationAttributeOptionId);
            db.AddInParameter(dbCommand, "SpecificationAttributeID", DbType.Int32, specificationAttributeId);
            db.AddInParameter(dbCommand, "Name", DbType.String, name);
            db.AddInParameter(dbCommand, "DisplayOrder", DbType.String, displayOrder);
            if (db.ExecuteNonQuery(dbCommand) > 0)
            {
                item = GetSpecificationAttributeOptionById(specificationAttributeOptionId, 0);
            }

            return(item);
        }
        /// <summary>
        /// Inserts a specification attribute option
        /// </summary>
        /// <param name="name">The name</param>
        /// <param name="displayOrder">Display order</param>
        /// <returns>Specification attribute option</returns>
        public override DBSpecificationAttributeOption InsertSpecificationAttributeOption(int specificationAttributeID, string name, int displayOrder)
        {
            DBSpecificationAttributeOption sao = null;

            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_SpecificationAttributeOptionInsert");

            db.AddOutParameter(dbCommand, "SpecificationAttributeOptionID", DbType.Int32, 0);
            db.AddInParameter(dbCommand, "SpecificationAttributeID", DbType.Int32, specificationAttributeID);
            db.AddInParameter(dbCommand, "Name", DbType.String, name);
            db.AddInParameter(dbCommand, "DisplayOrder", DbType.String, displayOrder);

            if (db.ExecuteNonQuery(dbCommand) > 0)
            {
                int saoID = Convert.ToInt32(db.GetParameterValue(dbCommand, "@SpecificationAttributeOptionID"));
                sao = GetSpecificationAttributeOptionByID(saoID);
            }
            return(sao);
        }
        /// <summary>
        /// Gets a specification attribute option
        /// </summary>
        /// <param name="specificationAttributeOptionID">The specification attribute option identifier</param>
        /// <returns>Specification attribute option</returns>
        public override DBSpecificationAttributeOption GetSpecificationAttributeOptionByID(int specificationAttributeOptionID)
        {
            DBSpecificationAttributeOption sao = null;

            if (specificationAttributeOptionID == 0)
            {
                return(sao);
            }
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_SpecificationAttributeOptionLoadByPrimaryKey");

            db.AddInParameter(dbCommand, "SpecificationAttributeOptionID", DbType.Int32, specificationAttributeOptionID);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    sao = GetSpecificationAttributeOptionFromReader(dataReader);
                }
            }
            return(sao);
        }