/// <summary> /// Updates the country /// </summary> /// <param name="countryId">The country identifier</param> /// <param name="name">The name</param> /// <param name="allowsRegistration">A value indicating whether registration is allowed to this country</param> /// <param name="allowsBilling">A value indicating whether billing is allowed to this country</param> /// <param name="allowsShipping">A value indicating whether shipping is allowed to this country</param> /// <param name="twoLetterIsoCode">The two letter ISO code</param> /// <param name="threeLetterIsoCode">The three letter ISO code</param> /// <param name="numericIsoCode">The numeric ISO code</param> /// <param name="published">A value indicating whether the entity is published</param> /// <param name="displayOrder">The display order</param> /// <returns>Country</returns> public override DBCountry UpdateCountry(int countryId, string name, bool allowsRegistration, bool allowsBilling, bool allowsShipping, string twoLetterIsoCode, string threeLetterIsoCode, int numericIsoCode, bool published, int displayOrder) { DBCountry item = null; Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_CountryUpdate"); db.AddInParameter(dbCommand, "CountryID", DbType.Int32, countryId); db.AddInParameter(dbCommand, "Name", DbType.String, name); db.AddInParameter(dbCommand, "AllowsRegistration", DbType.Boolean, allowsRegistration); db.AddInParameter(dbCommand, "AllowsBilling", DbType.Boolean, allowsBilling); db.AddInParameter(dbCommand, "AllowsShipping", DbType.Boolean, allowsShipping); db.AddInParameter(dbCommand, "TwoLetterISOCode", DbType.String, twoLetterIsoCode); db.AddInParameter(dbCommand, "ThreeLetterISOCode", DbType.String, threeLetterIsoCode); db.AddInParameter(dbCommand, "NumericISOCode", DbType.Int32, numericIsoCode); db.AddInParameter(dbCommand, "Published", DbType.Boolean, published); db.AddInParameter(dbCommand, "DisplayOrder", DbType.Int32, displayOrder); if (db.ExecuteNonQuery(dbCommand) > 0) { item = GetCountryById(countryId); } return(item); }
/// <summary> /// Updates the country /// </summary> /// <param name="CountryID">The country identifier</param> /// <param name="Name">The name</param> /// <param name="AllowsRegistration">A value indicating whether registration is allowed to this country</param> /// <param name="AllowsBilling">A value indicating whether billing is allowed to this country</param> /// <param name="AllowsShipping">A value indicating whether shipping is allowed to this country</param> /// <param name="TwoLetterISOCode">The two letter ISO code</param> /// <param name="ThreeLetterISOCode">The three letter ISO code</param> /// <param name="NumericISOCode">The numeric ISO code</param> /// <param name="Published">A value indicating whether the entity is published</param> /// <param name="DisplayOrder">The display order</param> /// <returns>Country</returns> public override DBCountry UpdateCountry(int CountryID, string Name, bool AllowsRegistration, bool AllowsBilling, bool AllowsShipping, string TwoLetterISOCode, string ThreeLetterISOCode, int NumericISOCode, bool Published, int DisplayOrder) { DBCountry country = null; Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_CountryUpdate"); db.AddInParameter(dbCommand, "CountryID", DbType.Int32, CountryID); db.AddInParameter(dbCommand, "Name", DbType.String, Name); db.AddInParameter(dbCommand, "AllowsRegistration", DbType.Boolean, AllowsRegistration); db.AddInParameter(dbCommand, "AllowsBilling", DbType.Boolean, AllowsBilling); db.AddInParameter(dbCommand, "AllowsShipping", DbType.Boolean, AllowsShipping); db.AddInParameter(dbCommand, "TwoLetterISOCode", DbType.String, TwoLetterISOCode); db.AddInParameter(dbCommand, "ThreeLetterISOCode", DbType.String, ThreeLetterISOCode); db.AddInParameter(dbCommand, "NumericISOCode", DbType.Int32, NumericISOCode); db.AddInParameter(dbCommand, "Published", DbType.Boolean, Published); db.AddInParameter(dbCommand, "DisplayOrder", DbType.Int32, DisplayOrder); if (db.ExecuteNonQuery(dbCommand) > 0) { country = GetCountryByID(CountryID); } return(country); }
private DBCountry GetCountryFromReader(IDataReader dataReader) { DBCountry country = new DBCountry(); country.CountryID = NopSqlDataHelper.GetInt(dataReader, "CountryID"); country.Name = NopSqlDataHelper.GetString(dataReader, "Name"); country.AllowsRegistration = NopSqlDataHelper.GetBoolean(dataReader, "AllowsRegistration"); country.AllowsBilling = NopSqlDataHelper.GetBoolean(dataReader, "AllowsBilling"); country.AllowsShipping = NopSqlDataHelper.GetBoolean(dataReader, "AllowsShipping"); country.TwoLetterISOCode = NopSqlDataHelper.GetString(dataReader, "TwoLetterISOCode"); country.ThreeLetterISOCode = NopSqlDataHelper.GetString(dataReader, "ThreeLetterISOCode"); country.NumericISOCode = NopSqlDataHelper.GetInt(dataReader, "NumericISOCode"); country.Published = NopSqlDataHelper.GetBoolean(dataReader, "Published"); country.DisplayOrder = NopSqlDataHelper.GetInt(dataReader, "DisplayOrder"); return country; }
private DBCountry GetCountryFromReader(IDataReader dataReader) { var item = new DBCountry(); item.CountryId = NopSqlDataHelper.GetInt(dataReader, "CountryID"); item.Name = NopSqlDataHelper.GetString(dataReader, "Name"); item.AllowsRegistration = NopSqlDataHelper.GetBoolean(dataReader, "AllowsRegistration"); item.AllowsBilling = NopSqlDataHelper.GetBoolean(dataReader, "AllowsBilling"); item.AllowsShipping = NopSqlDataHelper.GetBoolean(dataReader, "AllowsShipping"); item.TwoLetterIsoCode = NopSqlDataHelper.GetString(dataReader, "TwoLetterISOCode"); item.ThreeLetterIsoCode = NopSqlDataHelper.GetString(dataReader, "ThreeLetterISOCode"); item.NumericIsoCode = NopSqlDataHelper.GetInt(dataReader, "NumericISOCode"); item.Published = NopSqlDataHelper.GetBoolean(dataReader, "Published"); item.DisplayOrder = NopSqlDataHelper.GetInt(dataReader, "DisplayOrder"); return(item); }
/// <summary> /// Gets a country by three letter ISO code /// </summary> /// <param name="threeLetterIsoCode">Country three letter ISO code</param> /// <returns>Country</returns> public override DBCountry GetCountryByThreeLetterIsoCode(string threeLetterIsoCode) { DBCountry item = null; Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_CountryLoadByThreeLetterISOCode"); db.AddInParameter(dbCommand, "ThreeLetterISOCode", DbType.String, threeLetterIsoCode); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { item = GetCountryFromReader(dataReader); } } return(item); }
/// <summary> /// Gets a country /// </summary> /// <param name="countryId">Country identifier</param> /// <returns>Country</returns> public override DBCountry GetCountryById(int countryId) { DBCountry item = null; Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_CountryLoadByPrimaryKey"); db.AddInParameter(dbCommand, "CountryID", DbType.Int32, countryId); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { item = GetCountryFromReader(dataReader); } } return(item); }
/// <summary> /// Gets all countries that allow shipping /// </summary> /// <returns>Country collection</returns> public override DBCountryCollection GetAllCountriesForShipping(bool showHidden) { DBCountryCollection countryCollection = new DBCountryCollection(); Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_CountryLoadAllForShipping"); db.AddInParameter(dbCommand, "ShowHidden", DbType.Boolean, showHidden); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { DBCountry country = GetCountryFromReader(dataReader); countryCollection.Add(country); } } return(countryCollection); }
private static Country DBMapping(DBCountry dbItem) { if (dbItem == null) return null; Country item = new Country(); item.CountryID = dbItem.CountryID; item.Name = dbItem.Name; item.AllowsRegistration = dbItem.AllowsRegistration; item.AllowsBilling = dbItem.AllowsBilling; item.AllowsShipping = dbItem.AllowsShipping; item.TwoLetterISOCode = dbItem.TwoLetterISOCode; item.ThreeLetterISOCode = dbItem.ThreeLetterISOCode; item.NumericISOCode = dbItem.NumericISOCode; item.Published = dbItem.Published; item.DisplayOrder = dbItem.DisplayOrder; return item; }