/// <summary>
        /// Gets a state/province
        /// </summary>
        /// <param name="StateProvinceID">The state/province identifier</param>
        /// <returns>State/province</returns>
        public static StateProvince GetStateProvinceByID(int StateProvinceID)
        {
            if (StateProvinceID == 0)
            {
                return(null);
            }

            string key  = string.Format(STATEPROVINCES_BY_ID_KEY, StateProvinceID);
            object obj2 = NopCache.Get(key);

            if (StateProvinceManager.CacheEnabled && (obj2 != null))
            {
                return((StateProvince)obj2);
            }

            DBStateProvince dbItem = DBProviderManager <DBStateProvinceProvider> .Provider.GetStateProvinceByID(StateProvinceID);

            StateProvince stateProvince = DBMapping(dbItem);

            if (StateProvinceManager.CacheEnabled)
            {
                NopCache.Max(key, stateProvince);
            }
            return(stateProvince);
        }
        /// <summary>
        /// Gets a state/province
        /// </summary>
        /// <param name="Abbreviation">The state/province abbreviation</param>
        /// <returns>State/province</returns>
        public static StateProvince GetStateProvinceByAbbreviation(string Abbreviation)
        {
            DBStateProvince dbItem = DBProviderManager <DBStateProvinceProvider> .Provider.GetStateProvinceByAbbreviation(Abbreviation);

            StateProvince stateProvince = DBMapping(dbItem);

            return(stateProvince);
        }
        /// <summary>
        /// Updates a state/province
        /// </summary>
        /// <param name="StateProvinceID">The state/province identifier</param>
        /// <param name="CountryID">The country identifier</param>
        /// <param name="Name">The name</param>
        /// <param name="Abbreviation">The abbreviation</param>
        /// <param name="DisplayOrder">The display order</param>
        /// <returns>State/province</returns>
        public static StateProvince UpdateStateProvince(int StateProvinceID, int CountryID, string Name, string Abbreviation, int DisplayOrder)
        {
            DBStateProvince dbItem = DBProviderManager <DBStateProvinceProvider> .Provider.UpdateStateProvince(StateProvinceID, CountryID, Name, Abbreviation, DisplayOrder);

            StateProvince stateProvince = DBMapping(dbItem);

            if (StateProvinceManager.CacheEnabled)
            {
                NopCache.RemoveByPattern(STATEPROVINCES_PATTERN_KEY);
            }

            return(stateProvince);
        }
Ejemplo n.º 4
0
        private static StateProvince DBMapping(DBStateProvince dbItem)
        {
            if (dbItem == null)
            {
                return(null);
            }

            var item = new StateProvince();

            item.StateProvinceId = dbItem.StateProvinceId;
            item.CountryId       = dbItem.CountryId;
            item.Name            = dbItem.Name;
            item.Abbreviation    = dbItem.Abbreviation;
            item.DisplayOrder    = dbItem.DisplayOrder;

            return(item);
        }