private DBShippingByWeightAndCountry GetShippingByWeightAndCountryFromReader(IDataReader dataReader)
 {
     DBShippingByWeightAndCountry shippingByWeightAndCountry = new DBShippingByWeightAndCountry();
     shippingByWeightAndCountry.ShippingByWeightAndCountryID = NopSqlDataHelper.GetInt(dataReader, "ShippingByWeightAndCountryID");
     shippingByWeightAndCountry.ShippingMethodID = NopSqlDataHelper.GetInt(dataReader, "ShippingMethodID");
     shippingByWeightAndCountry.CountryID = NopSqlDataHelper.GetInt(dataReader, "CountryID");
     shippingByWeightAndCountry.From = NopSqlDataHelper.GetDecimal(dataReader, "From");
     shippingByWeightAndCountry.To = NopSqlDataHelper.GetDecimal(dataReader, "To");
     shippingByWeightAndCountry.UsePercentage = NopSqlDataHelper.GetBoolean(dataReader, "UsePercentage");
     shippingByWeightAndCountry.ShippingChargePercentage = NopSqlDataHelper.GetDecimal(dataReader, "ShippingChargePercentage");
     shippingByWeightAndCountry.ShippingChargeAmount = NopSqlDataHelper.GetDecimal(dataReader, "ShippingChargeAmount");
     return shippingByWeightAndCountry;
 }
        private DBShippingByWeightAndCountry GetShippingByWeightAndCountryFromReader(IDataReader dataReader)
        {
            DBShippingByWeightAndCountry shippingByWeightAndCountry = new DBShippingByWeightAndCountry();

            shippingByWeightAndCountry.ShippingByWeightAndCountryID = NopSqlDataHelper.GetInt(dataReader, "ShippingByWeightAndCountryID");
            shippingByWeightAndCountry.ShippingMethodID             = NopSqlDataHelper.GetInt(dataReader, "ShippingMethodID");
            shippingByWeightAndCountry.CountryID                = NopSqlDataHelper.GetInt(dataReader, "CountryID");
            shippingByWeightAndCountry.From                     = NopSqlDataHelper.GetDecimal(dataReader, "From");
            shippingByWeightAndCountry.To                       = NopSqlDataHelper.GetDecimal(dataReader, "To");
            shippingByWeightAndCountry.UsePercentage            = NopSqlDataHelper.GetBoolean(dataReader, "UsePercentage");
            shippingByWeightAndCountry.ShippingChargePercentage = NopSqlDataHelper.GetDecimal(dataReader, "ShippingChargePercentage");
            shippingByWeightAndCountry.ShippingChargeAmount     = NopSqlDataHelper.GetDecimal(dataReader, "ShippingChargeAmount");
            return(shippingByWeightAndCountry);
        }
        /// <summary>
        /// Gets a ShippingByWeightAndCountry
        /// </summary>
        /// <param name="ShippingByWeightAndCountryID">ShippingByWeightAndCountry identifier</param>
        /// <returns>ShippingByWeightAndCountry</returns>
        public override DBShippingByWeightAndCountry GetByID(int ShippingByWeightAndCountryID)
        {
            DBShippingByWeightAndCountry shippingByWeightAndCountry = null;
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_ShippingByWeightAndCountryLoadByPrimaryKey");

            db.AddInParameter(dbCommand, "ShippingByWeightAndCountryID", DbType.Int32, ShippingByWeightAndCountryID);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    shippingByWeightAndCountry = GetShippingByWeightAndCountryFromReader(dataReader);
                }
            }
            return(shippingByWeightAndCountry);
        }
        /// <summary>
        /// Gets all ShippingByWeightAndCountrys
        /// </summary>
        /// <returns>ShippingByWeightAndCountry collection</returns>
        public override DBShippingByWeightAndCountryCollection GetAll()
        {
            DBShippingByWeightAndCountryCollection shippingByWeightAndCountryCollection = new DBShippingByWeightAndCountryCollection();
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_ShippingByWeightAndCountryLoadAll");

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    DBShippingByWeightAndCountry shippingByWeightAndCountry = GetShippingByWeightAndCountryFromReader(dataReader);
                    shippingByWeightAndCountryCollection.Add(shippingByWeightAndCountry);
                }
            }

            return(shippingByWeightAndCountryCollection);
        }
        private static ShippingByWeightAndCountry DBMapping(DBShippingByWeightAndCountry dbItem)
        {
            if (dbItem == null)
                return null;

            ShippingByWeightAndCountry item = new ShippingByWeightAndCountry();
            item.ShippingByWeightAndCountryID = dbItem.ShippingByWeightAndCountryID;
            item.ShippingMethodID = dbItem.ShippingMethodID;
            item.CountryID = dbItem.CountryID;
            item.From = dbItem.From;
            item.To = dbItem.To;
            item.UsePercentage = dbItem.UsePercentage;
            item.ShippingChargePercentage = dbItem.ShippingChargePercentage;
            item.ShippingChargeAmount = dbItem.ShippingChargeAmount;

            return item;
        }
        /// <summary>
        /// Gets all ShippingByWeightAndCountrys by shipping method identifier
        /// </summary>
        /// <param name="ShippingMethodID">The shipping method identifier</param>
        /// <param name="CountryID">The country identifier</param>
        /// <returns>ShippingByWeightAndCountry collection</returns>
        public override DBShippingByWeightAndCountryCollection GetAllByShippingMethodIDAndCountryID(int ShippingMethodID, int CountryID)
        {
            DBShippingByWeightAndCountryCollection shippingByWeightAndCountryCollection = new DBShippingByWeightAndCountryCollection();
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_ShippingByWeightAndCountryLoadByShippingMethodIDAndCountryID");

            db.AddInParameter(dbCommand, "ShippingMethodID", DbType.Int32, ShippingMethodID);
            db.AddInParameter(dbCommand, "CountryID", DbType.Int32, CountryID);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    DBShippingByWeightAndCountry shippingByWeightAndCountry = GetShippingByWeightAndCountryFromReader(dataReader);
                    shippingByWeightAndCountryCollection.Add(shippingByWeightAndCountry);
                }
            }

            return(shippingByWeightAndCountryCollection);
        }
        /// <summary>
        /// Updates the ShippingByWeightAndCountry
        /// </summary>
        /// <param name="ShippingByWeightAndCountryID">The ShippingByWeightAndCountry identifier</param>
        /// <param name="ShippingMethodID">The shipping method identifier</param>
        /// <param name="CountryID">The country identifier</param>
        /// <param name="From">The "from" value</param>
        /// <param name="To">The "to" value</param>
        /// <param name="UsePercentage">A value indicating whether to use percentage</param>
        /// <param name="ShippingChargePercentage">The shipping charge percentage</param>
        /// <param name="ShippingChargeAmount">The shipping charge amount</param>
        /// <returns>ShippingByWeightAndCountry</returns>
        public override DBShippingByWeightAndCountry UpdateShippingByWeightAndCountry(int ShippingByWeightAndCountryID,
                                                                                      int ShippingMethodID, int CountryID, decimal From, decimal To, bool UsePercentage, decimal ShippingChargePercentage, decimal ShippingChargeAmount)
        {
            DBShippingByWeightAndCountry shippingByWeightAndCountry = null;
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_ShippingByWeightAndCountryUpdate");

            db.AddInParameter(dbCommand, "ShippingByWeightAndCountryID", DbType.Int32, ShippingByWeightAndCountryID);
            db.AddInParameter(dbCommand, "ShippingMethodID", DbType.Int32, ShippingMethodID);
            db.AddInParameter(dbCommand, "CountryID", DbType.Int32, CountryID);
            db.AddInParameter(dbCommand, "From", DbType.Decimal, From);
            db.AddInParameter(dbCommand, "To", DbType.Decimal, To);
            db.AddInParameter(dbCommand, "UsePercentage", DbType.Boolean, UsePercentage);
            db.AddInParameter(dbCommand, "ShippingChargePercentage", DbType.Decimal, ShippingChargePercentage);
            db.AddInParameter(dbCommand, "ShippingChargeAmount", DbType.Decimal, ShippingChargeAmount);
            if (db.ExecuteNonQuery(dbCommand) > 0)
            {
                shippingByWeightAndCountry = GetByID(ShippingByWeightAndCountryID);
            }

            return(shippingByWeightAndCountry);
        }
        /// <summary>
        /// Updates the ShippingByWeightAndCountry
        /// </summary>
        /// <param name="shippingByWeightAndCountryId">The ShippingByWeightAndCountry identifier</param>
        /// <param name="shippingMethodId">The shipping method identifier</param>
        /// <param name="countryId">The country identifier</param>
        /// <param name="from">The "from" value</param>
        /// <param name="to">The "to" value</param>
        /// <param name="usePercentage">A value indicating whether to use percentage</param>
        /// <param name="shippingChargePercentage">The shipping charge percentage</param>
        /// <param name="shippingChargeAmount">The shipping charge amount</param>
        /// <returns>ShippingByWeightAndCountry</returns>
        public override DBShippingByWeightAndCountry UpdateShippingByWeightAndCountry(int shippingByWeightAndCountryId,
                                                                                      int shippingMethodId, int countryId, decimal from, decimal to, bool usePercentage,
                                                                                      decimal shippingChargePercentage, decimal shippingChargeAmount)
        {
            DBShippingByWeightAndCountry item = null;
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_ShippingByWeightAndCountryUpdate");

            db.AddInParameter(dbCommand, "ShippingByWeightAndCountryID", DbType.Int32, shippingByWeightAndCountryId);
            db.AddInParameter(dbCommand, "ShippingMethodID", DbType.Int32, shippingMethodId);
            db.AddInParameter(dbCommand, "CountryID", DbType.Int32, countryId);
            db.AddInParameter(dbCommand, "From", DbType.Decimal, from);
            db.AddInParameter(dbCommand, "To", DbType.Decimal, to);
            db.AddInParameter(dbCommand, "UsePercentage", DbType.Boolean, usePercentage);
            db.AddInParameter(dbCommand, "ShippingChargePercentage", DbType.Decimal, shippingChargePercentage);
            db.AddInParameter(dbCommand, "ShippingChargeAmount", DbType.Decimal, shippingChargeAmount);
            if (db.ExecuteNonQuery(dbCommand) > 0)
            {
                item = GetById(shippingByWeightAndCountryId);
            }

            return(item);
        }