private static StateProvinceCollection DBMapping(DBStateProvinceCollection dbCollection) { if (dbCollection == null) { return(null); } var collection = new StateProvinceCollection(); foreach (var dbItem in dbCollection) { var item = DBMapping(dbItem); collection.Add(item); } return(collection); }
/// <summary> /// Gets a state/province collection by country identifier /// </summary> /// <param name="CountryID">Country identifier</param> /// <returns>State/province collection</returns> public static StateProvinceCollection GetStateProvincesByCountryID(int CountryID) { string key = string.Format(STATEPROVINCES_ALL_KEY, CountryID); object obj2 = NopCache.Get(key); if (StateProvinceManager.CacheEnabled && (obj2 != null)) { return((StateProvinceCollection)obj2); } DBStateProvinceCollection dbCollection = DBProviderManager <DBStateProvinceProvider> .Provider.GetStateProvincesByCountryID(CountryID); StateProvinceCollection stateProvinceCollection = DBMapping(dbCollection); if (StateProvinceManager.CacheEnabled) { NopCache.Max(key, stateProvinceCollection); } return(stateProvinceCollection); }
/// <summary> /// Gets a state/province collection by country identifier /// </summary> /// <param name="CountryID">Country identifier</param> /// <returns>State/province collection</returns> public override DBStateProvinceCollection GetStateProvincesByCountryID(int CountryID) { DBStateProvinceCollection stateProvinceCollection = new DBStateProvinceCollection(); if (CountryID == 0) { return(stateProvinceCollection); } Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_StateProvinceLoadAllByCountryID"); db.AddInParameter(dbCommand, "CountryID", DbType.Int32, CountryID); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { DBStateProvince stateProvince = GetStateProvinceFromReader(dataReader); stateProvinceCollection.Add(stateProvince); } } return(stateProvinceCollection); }
/// <summary> /// Gets a state/province collection by country identifier /// </summary> /// <param name="countryId">Country identifier</param> /// <returns>State/province collection</returns> public override DBStateProvinceCollection GetStateProvincesByCountryId(int countryId) { var result = new DBStateProvinceCollection(); if (countryId == 0) { return(result); } Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_StateProvinceLoadAllByCountryID"); db.AddInParameter(dbCommand, "CountryID", DbType.Int32, countryId); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { var item = GetStateProvinceFromReader(dataReader); result.Add(item); } } return(result); }