예제 #1
0
        /// <summary>
        /// Gets the jurisdictions and jurisdiction groups for the specified jurisdiction type.
        /// </summary>
        /// <param name="jurisdictionType">JurisdictionType. 1 - tax, 2 - shipping. null - all jurisdictions.</param>
        /// <returns></returns>
        public static JurisdictionDto GetJurisdictions(JurisdictionType?jurisdictionType)
        {
            // Assign new cache key, specific for site guid and response groups requested
            string cacheKey = OrderCache.CreateCacheKey("jurisdictions", jurisdictionType.HasValue ? jurisdictionType.Value.ToString() : String.Empty);

            JurisdictionDto dto = null;

            // check cache first
            object cachedObject = OrderCache.Get(cacheKey);

            if (cachedObject != null)
            {
                dto = (JurisdictionDto)cachedObject;
            }

            // Load the object
            if (dto == null)
            {
                DataCommand cmd = OrderDataHelper.CreateConfigDataCommand();
                cmd.CommandText = "[ecf_Jurisdiction]";
                cmd.Parameters  = new DataParameters();
                cmd.Parameters.Add(new DataParameter("ApplicationId", OrderConfiguration.Instance.ApplicationId, DataParameterType.UniqueIdentifier));
                if (jurisdictionType.HasValue)
                {
                    cmd.Parameters.Add(new DataParameter("JurisdictionType", jurisdictionType.Value.GetHashCode(), DataParameterType.Int));
                }
                cmd.DataSet      = new JurisdictionDto();
                cmd.TableMapping = DataHelper.MapTables("Jurisdiction", "JurisdictionGroup", "JurisdictionRelation");

                DataResult results = DataService.LoadDataSet(cmd);

                dto = (JurisdictionDto)results.DataSet;

                // Insert to the cache collection
                OrderCache.Insert(cacheKey, dto, OrderConfiguration.Instance.Cache.PaymentCollectionTimeout);
            }

            return(dto);
        }
예제 #2
0
        /// <summary>
        /// Gets the shipping methods.
        /// </summary>
        /// <param name="languageid">The languageid.</param>
        /// <param name="returnInactive">if set to <c>true</c> [return inactive].</param>
        /// <returns></returns>
        public static ShippingMethodDto GetShippingMethods(string languageid, bool returnInactive)
        {
            // Assign new cache key, specific for site guid and response groups requested
            string cacheKey = OrderCache.CreateCacheKey("shipping-methods", languageid, returnInactive.ToString());

            ShippingMethodDto dto = null;

            // check cache first
            object cachedObject = OrderCache.Get(cacheKey);

            if (cachedObject != null)
            {
                dto = (ShippingMethodDto)cachedObject;
            }


            // Load the object
            if (dto == null)
            {
                DataCommand cmd = OrderDataHelper.CreateConfigDataCommand();
                cmd.CommandText = "[ecf_ShippingMethod_Language]";
                cmd.Parameters  = new DataParameters();
                cmd.Parameters.Add(new DataParameter("ApplicationId", OrderConfiguration.Instance.ApplicationId, DataParameterType.UniqueIdentifier));
                cmd.Parameters.Add(new DataParameter("LanguageId", String.IsNullOrEmpty(languageid) ? null : languageid, DataParameterType.NVarChar, 10));
                cmd.Parameters.Add(new DataParameter("ReturnInactive", returnInactive, DataParameterType.Bit));
                cmd.DataSet      = new ShippingMethodDto();
                cmd.TableMapping = DataHelper.MapTables("ShippingOption", "ShippingOptionParameter", "ShippingMethod", "ShippingMethodParameter", "ShippingMethodCase", "ShippingCountry", "ShippingRegion", "ShippingPaymentRestriction", "Package", "ShippingPackage");

                DataResult results = DataService.LoadDataSet(cmd);

                dto = (ShippingMethodDto)results.DataSet;

                // Insert to the cache collection
                OrderCache.Insert(cacheKey, dto, OrderConfiguration.Instance.Cache.ShippingCollectionTimeout);
            }

            return(dto);
        }
예제 #3
0
        /// <summary>
        /// Gets the countries.
        /// </summary>
        /// <param name="returnInactive">If true, all countries will be returned, otherwise only visible.</param>
        /// <returns></returns>
        public static CountryDto GetCountries(bool returnInactive)
        {
            // Assign new cache key, specific for site guid and response groups requested
            string cacheKey = OrderCache.CreateCacheKey("countries", returnInactive.ToString());

            CountryDto dto = null;

            // check cache first
            object cachedObject = OrderCache.Get(cacheKey);

            if (cachedObject != null)
            {
                dto = (CountryDto)cachedObject;
            }

            // Load the object
            if (dto == null)
            {
                DataCommand cmd = OrderDataHelper.CreateConfigDataCommand();
                cmd.CommandText = "[ecf_Country]";
                cmd.Parameters  = new DataParameters();
                cmd.Parameters.Add(new DataParameter("ApplicationId", OrderConfiguration.Instance.ApplicationId, DataParameterType.UniqueIdentifier));
                cmd.Parameters.Add(new DataParameter("ReturnInactive", returnInactive, DataParameterType.Bit));
                cmd.DataSet      = new CountryDto();
                cmd.TableMapping = DataHelper.MapTables("Country", "StateProvince");

                DataResult results = DataService.LoadDataSet(cmd);

                dto = (CountryDto)results.DataSet;

                // Insert to the cache collection
                OrderCache.Insert(cacheKey, dto, OrderConfiguration.Instance.Cache.CountryCollectionTimeout);
            }

            return(dto);
        }