/// <summary>
        /// Gets a currency
        /// </summary>
        /// <param name="currencyId">Currency identifier</param>
        /// <returns>Currency</returns>
        public static Currency GetCurrencyById(int currencyId)
        {
            if (currencyId == 0)
            {
                return(null);
            }

            string key  = string.Format(CURRENCIES_BY_ID_KEY, currencyId);
            object obj2 = NopCache.Get(key);

            if (CurrencyManager.CacheEnabled && (obj2 != null))
            {
                return((Currency)obj2);
            }

            DBCurrency dbItem = DBProviderManager <DBCurrencyProvider> .Provider.GetCurrencyById(currencyId);

            Currency currency = DBMapping(dbItem);

            if (CurrencyManager.CacheEnabled)
            {
                NopCache.Max(key, currency);
            }
            return(currency);
        }
        /// <summary>
        /// Gets a shipping method
        /// </summary>
        /// <param name="shippingMethodId">The shipping method identifier</param>
        /// <returns>Shipping method</returns>
        public static ShippingMethod GetShippingMethodById(int shippingMethodId)
        {
            if (shippingMethodId == 0)
            {
                return(null);
            }

            string key  = string.Format(SHIPPINGMETHODS_BY_ID_KEY, shippingMethodId);
            object obj2 = NopCache.Get(key);

            if (ShippingMethodManager.CacheEnabled && (obj2 != null))
            {
                return((ShippingMethod)obj2);
            }

            var dbItem = DBProviderManager <DBShippingMethodProvider> .Provider.GetShippingMethodById(shippingMethodId);

            var shippingMethod = DBMapping(dbItem);

            if (ShippingMethodManager.CacheEnabled)
            {
                NopCache.Max(key, shippingMethod);
            }
            return(shippingMethod);
        }
示例#3
0
        /// <summary>
        /// Gets a manufacturer template
        /// </summary>
        /// <param name="manufacturerTemplateId">Manufacturer template identifier</param>
        /// <returns>Manufacturer template</returns>
        public static ManufacturerTemplate GetManufacturerTemplateById(int manufacturerTemplateId)
        {
            if (manufacturerTemplateId == 0)
            {
                return(null);
            }

            string key  = string.Format(MANUFACTURERTEMPLATES_BY_ID_KEY, manufacturerTemplateId);
            object obj2 = NopCache.Get(key);

            if (TemplateManager.CacheEnabled && (obj2 != null))
            {
                return((ManufacturerTemplate)obj2);
            }

            var dbItem = DBProviderManager <DBTemplateProvider> .Provider.GetManufacturerTemplateById(manufacturerTemplateId);

            var manufacturerTemplate = DBMapping(dbItem);

            if (TemplateManager.CacheEnabled)
            {
                NopCache.Max(key, manufacturerTemplate);
            }
            return(manufacturerTemplate);
        }
        /// <summary>
        /// Gets a manufacturer
        /// </summary>
        /// <param name="ManufacturerID">Manufacturer identifier</param>
        /// <returns>Manufacturer</returns>
        public static Manufacturer GetManufacturerByID(int ManufacturerID)
        {
            if (ManufacturerID == 0)
            {
                return(null);
            }

            string key  = string.Format(MANUFACTURERS_BY_ID_KEY, ManufacturerID);
            object obj2 = NopCache.Get(key);

            if (ManufacturerManager.ManufacturersCacheEnabled && (obj2 != null))
            {
                return((Manufacturer)obj2);
            }

            DBManufacturer dbItem = DBProviderManager <DBManufacturerProvider> .Provider.GetManufacturerByID(ManufacturerID);

            Manufacturer manufacturer = DBMapping(dbItem);

            if (ManufacturerManager.ManufacturersCacheEnabled)
            {
                NopCache.Max(key, manufacturer);
            }
            return(manufacturer);
        }
示例#5
0
        /// <summary>
        /// Gets a poll
        /// </summary>
        /// <param name="PollID">The poll identifier</param>
        /// <returns>Poll</returns>
        public static Poll GetPollByID(int PollID)
        {
            if (PollID == 0)
            {
                return(null);
            }

            string key  = string.Format(POLLS_BY_ID_KEY, PollID);
            object obj2 = NopCache.Get(key);

            if (PollManager.CacheEnabled && (obj2 != null))
            {
                return((Poll)obj2);
            }

            DBPoll dbItem = DBProviderManager <DBPollProvider> .Provider.GetPollByID(PollID);

            Poll poll = DBMapping(dbItem);

            if (PollManager.CacheEnabled)
            {
                NopCache.Max(key, poll);
            }
            return(poll);
        }
示例#6
0
        /// <summary>
        /// Gets a product category mapping collection
        /// </summary>
        /// <param name="productId">Product identifier</param>
        /// <returns>Product category mapping collection</returns>
        public static ProductCategoryCollection GetProductCategoriesByProductId(int productId)
        {
            if (productId == 0)
            {
                return(new ProductCategoryCollection());
            }

            bool   showHidden = NopContext.Current.IsAdmin;
            string key        = string.Format(PRODUCTCATEGORIES_ALLBYPRODUCTID_KEY, showHidden, productId);
            object obj2       = NopCache.Get(key);

            if (CategoryManager.MappingsCacheEnabled && (obj2 != null))
            {
                return((ProductCategoryCollection)obj2);
            }

            var dbCollection = DBProviderManager <DBCategoryProvider> .Provider.GetProductCategoriesByProductId(productId, showHidden);

            var productCategoryCollection = DBMapping(dbCollection);

            if (CategoryManager.MappingsCacheEnabled)
            {
                NopCache.Max(key, productCategoryCollection);
            }
            return(productCategoryCollection);
        }
示例#7
0
        /// <summary>
        /// Gets a news
        /// </summary>
        /// <param name="NewsID">The news identifier</param>
        /// <returns>News</returns>
        public static News GetNewsByID(int NewsID)
        {
            if (NewsID == 0)
            {
                return(null);
            }

            string key  = string.Format(NEWS_BY_ID_KEY, NewsID);
            object obj2 = NopCache.Get(key);

            if (NewsManager.CacheEnabled && (obj2 != null))
            {
                return((News)obj2);
            }

            DBNews dbItem = DBProviderManager <DBNewsProvider> .Provider.GetNewsByID(NewsID);

            News news = DBMapping(dbItem);

            if (NewsManager.CacheEnabled)
            {
                NopCache.Max(key, news);
            }
            return(news);
        }
示例#8
0
        /// <summary>
        /// Gets a customer action by identifier
        /// </summary>
        /// <param name="customerActionId">Customer action identifier</param>
        /// <returns>Customer action</returns>
        public static CustomerAction GetCustomerActionById(int customerActionId)
        {
            if (customerActionId == 0)
            {
                return(null);
            }

            string key  = string.Format(CUSTOMERACTIONS_BY_ID_KEY, customerActionId);
            object obj2 = NopCache.Get(key);

            if (ACLManager.CacheEnabled && (obj2 != null))
            {
                return((CustomerAction)obj2);
            }

            var dbItem = DBProviderManager <DBACLProvider> .Provider.GetCustomerActionById(customerActionId);

            var customerAction = DBMapping(dbItem);

            if (ACLManager.CacheEnabled)
            {
                NopCache.Max(key, customerAction);
            }
            return(customerAction);
        }
示例#9
0
        /// <summary>
        /// Gets a measure dimension by identifier
        /// </summary>
        /// <param name="measureDimensionId">Measure dimension identifier</param>
        /// <returns>Measure dimension</returns>
        public static MeasureDimension GetMeasureDimensionById(int measureDimensionId)
        {
            if (measureDimensionId == 0)
            {
                return(null);
            }

            string key  = string.Format(MEASUREDIMENSIONS_BY_ID_KEY, measureDimensionId);
            object obj2 = NopCache.Get(key);

            if (MeasureManager.CacheEnabled && (obj2 != null))
            {
                return((MeasureDimension)obj2);
            }

            var dbItem = DBProviderManager <DBMeasureProvider> .Provider.GetMeasureDimensionById(measureDimensionId);

            var measureDimension = DBMapping(dbItem);

            if (MeasureManager.CacheEnabled)
            {
                NopCache.Max(key, measureDimension);
            }
            return(measureDimension);
        }
示例#10
0
        /// <summary>
        /// Gets a tax rate
        /// </summary>
        /// <param name="taxRateId">Tax rate identifier</param>
        /// <returns>Tax rate</returns>
        public static TaxRate GetTaxRateById(int taxRateId)
        {
            if (taxRateId == 0)
            {
                return(null);
            }

            string key  = string.Format(TAXRATE_BY_ID_KEY, taxRateId);
            object obj2 = NopCache.Get(key);

            if (TaxRateManager.CacheEnabled && (obj2 != null))
            {
                return((TaxRate)obj2);
            }

            var dbItem = DBProviderManager <DBTaxRateProvider> .Provider.GetTaxRateById(taxRateId);

            var taxRate = DBMapping(dbItem);

            if (TaxRateManager.CacheEnabled)
            {
                NopCache.Max(key, taxRate);
            }
            return(taxRate);
        }
        /// <summary>
        /// Gets product manufacturer collection
        /// </summary>
        /// <param name="manufacturerId">Manufacturer identifier</param>
        /// <returns>Product manufacturer collection</returns>
        public static ProductManufacturerCollection GetProductManufacturersByManufacturerId(int manufacturerId)
        {
            if (manufacturerId == 0)
            {
                return(new ProductManufacturerCollection());
            }

            bool   showHidden = NopContext.Current.IsAdmin;
            string key        = string.Format(PRODUCTMANUFACTURERS_ALLBYMANUFACTURERID_KEY, showHidden, manufacturerId);
            object obj2       = NopCache.Get(key);

            if (ManufacturerManager.MappingsCacheEnabled && (obj2 != null))
            {
                return((ProductManufacturerCollection)obj2);
            }

            var dbCollection = DBProviderManager <DBManufacturerProvider> .Provider.GetProductManufacturersByManufacturerId(manufacturerId, showHidden);

            var productManufacturerCollection = DBMapping(dbCollection);

            if (ManufacturerManager.MappingsCacheEnabled)
            {
                NopCache.Max(key, productManufacturerCollection);
            }
            return(productManufacturerCollection);
        }
示例#12
0
        /// <summary>
        /// Gets a shipping rate computation method
        /// </summary>
        /// <param name="ShippingRateComputationMethodID">Shipping rate computation method identifier</param>
        /// <returns>Shipping rate computation method</returns>
        public static ShippingRateComputationMethod GetShippingRateComputationMethodByID(int ShippingRateComputationMethodID)
        {
            if (ShippingRateComputationMethodID == 0)
            {
                return(null);
            }

            string key  = string.Format(SHIPPINGRATECOMPUTATIONMETHODS_BY_ID_KEY, ShippingRateComputationMethodID);
            object obj2 = NopCache.Get(key);

            if (ShippingRateComputationMethodManager.CacheEnabled && (obj2 != null))
            {
                return((ShippingRateComputationMethod)obj2);
            }

            DBShippingRateComputationMethod dbItem = DBProviderManager <DBShippingRateComputationMethodProvider> .Provider.GetShippingRateComputationMethodByID(ShippingRateComputationMethodID);

            ShippingRateComputationMethod shippingRateComputationMethod = DBMapping(dbItem);

            if (ShippingRateComputationMethodManager.CacheEnabled)
            {
                NopCache.Max(key, shippingRateComputationMethod);
            }
            return(shippingRateComputationMethod);
        }
        /// <summary>
        /// Gets a product variant attribute value
        /// </summary>
        /// <param name="ProductVariantAttributeValueID">Product variant attribute value identifier</param>
        /// <returns>Product variant attribute value</returns>
        public static ProductVariantAttributeValue GetProductVariantAttributeValueByID(int ProductVariantAttributeValueID)
        {
            if (ProductVariantAttributeValueID == 0)
            {
                return(null);
            }

            string key  = string.Format(PRODUCTVARIANTATTRIBUTEVALUES_BY_ID_KEY, ProductVariantAttributeValueID);
            object obj2 = NopCache.Get(key);

            if (ProductAttributeManager.CacheEnabled && (obj2 != null))
            {
                return((ProductVariantAttributeValue)obj2);
            }

            DBProductVariantAttributeValue dbItem = DBProviderManager <DBProductAttributeProvider> .Provider.GetProductVariantAttributeValueByID(ProductVariantAttributeValueID);

            ProductVariantAttributeValue productVariantAttributeValue = DBMapping(dbItem);

            if (ProductAttributeManager.CacheEnabled)
            {
                NopCache.Max(key, productVariantAttributeValue);
            }
            return(productVariantAttributeValue);
        }
        /// <summary>
        /// Gets a payment status by ID
        /// </summary>
        /// <param name="PaymentStatusID">payment status identifier</param>
        /// <returns>Payment status</returns>
        public static PaymentStatus GetPaymentStatusByID(int PaymentStatusID)
        {
            if (PaymentStatusID == 0)
            {
                return(null);
            }

            string key  = string.Format(PAYMENTSTATUSES_BY_ID_KEY, PaymentStatusID);
            object obj2 = NopCache.Get(key);

            if (PaymentStatusManager.CacheEnabled && (obj2 != null))
            {
                return((PaymentStatus)obj2);
            }

            DBPaymentStatus dbItem = DBProviderManager <DBPaymentStatusProvider> .Provider.GetPaymentStatusByID(PaymentStatusID);

            PaymentStatus paymentStatus = DBMapping(dbItem);

            if (PaymentStatusManager.CacheEnabled)
            {
                NopCache.Max(key, paymentStatus);
            }
            return(paymentStatus);
        }
示例#15
0
        /// <summary>
        /// Gets a payment method
        /// </summary>
        /// <param name="paymentMethodId">Payment method identifier</param>
        /// <returns>Payment method</returns>
        public static PaymentMethod GetPaymentMethodById(int paymentMethodId)
        {
            //PaymentMethod pm = new PaymentMethod();
            //pm.IsActive= true;
            //pm.
            //pm.PaymentMethod
            paymentMethodId = 18; //~~ here you should specify the payment method id that you want to use by default
            if (paymentMethodId == 0)
            {
                return(null);
            }

            string key  = string.Format(PAYMENTMETHODS_BY_ID_KEY, paymentMethodId);
            object obj2 = NopCache.Get(key);

            if (PaymentMethodManager.CacheEnabled && (obj2 != null))
            {
                return((PaymentMethod)obj2);
            }

            var dbItem = DBProviderManager <DBPaymentMethodProvider> .Provider.GetPaymentMethodById(paymentMethodId);

            var paymentMethod = DBMapping(dbItem);

            if (PaymentMethodManager.CacheEnabled)
            {
                NopCache.Max(key, paymentMethod);
            }
            return(paymentMethod);
        }
示例#16
0
        /// <summary>
        /// Gets a measure weight by identifier
        /// </summary>
        /// <param name="measureWeightId">Measure weight identifier</param>
        /// <returns>Measure weight</returns>
        public static MeasureWeight GetMeasureWeightById(int measureWeightId)
        {
            if (measureWeightId == 0)
            {
                return(null);
            }

            string key  = string.Format(MEASUREWEIGHTS_BY_ID_KEY, measureWeightId);
            object obj2 = NopCache.Get(key);

            if (MeasureManager.CacheEnabled && (obj2 != null))
            {
                return((MeasureWeight)obj2);
            }

            var dbItem = DBProviderManager <DBMeasureProvider> .Provider.GetMeasureWeightById(measureWeightId);

            var measureWeight = DBMapping(dbItem);

            if (MeasureManager.CacheEnabled)
            {
                NopCache.Max(key, measureWeight);
            }
            return(measureWeight);
        }
示例#17
0
        /// <summary>
        /// Gets a credit card type
        /// </summary>
        /// <param name="CreditCardTypeID">Credit card type identifier</param>
        /// <returns>Credit card type</returns>
        public static CreditCardType GetCreditCardTypeByID(int CreditCardTypeID)
        {
            if (CreditCardTypeID == 0)
            {
                return(null);
            }

            string key  = string.Format(CREDITCARDS_BY_ID_KEY, CreditCardTypeID);
            object obj2 = NopCache.Get(key);

            if (CreditCardTypeManager.CacheEnabled && (obj2 != null))
            {
                return((CreditCardType)obj2);
            }

            DBCreditCardType dbItem = DBProviderManager <DBCreditCardTypeProvider> .Provider.GetCreditCardTypeByID(CreditCardTypeID);

            CreditCardType creditCardType = DBMapping(dbItem);

            if (CreditCardTypeManager.CacheEnabled)
            {
                NopCache.Max(key, creditCardType);
            }
            return(creditCardType);
        }
        /// <summary>
        /// Gets a specification attribute option
        /// </summary>
        /// <param name="SpecificationAttributeOptionID">The specification attribute option identifier</param>
        /// <returns>Specification attribute option</returns>
        public static SpecificationAttributeOption GetSpecificationAttributeOptionByID(int specificationAttributeOptionID)
        {
            if (specificationAttributeOptionID == 0)
            {
                return(null);
            }

            string key  = string.Format(SPECIFICATIONATTRIBUTEOPTION_BY_ID_KEY, specificationAttributeOptionID);
            object obj2 = NopCache.Get(key);

            if (SpecificationAttributeManager.CacheEnabled && (obj2 != null))
            {
                return((SpecificationAttributeOption)obj2);
            }

            DBSpecificationAttributeOption dbItem = DBProviderManager <DBSpecificationAttributeProvider> .Provider.GetSpecificationAttributeOptionByID(specificationAttributeOptionID);

            SpecificationAttributeOption specificationAttribute = DBMapping(dbItem);

            if (SpecificationAttributeManager.CacheEnabled)
            {
                NopCache.Max(key, specificationAttribute);
            }
            return(specificationAttribute);
        }
示例#19
0
        /// <summary>
        /// Gets a product category mapping
        /// </summary>
        /// <param name="productCategoryId">Product category mapping identifier</param>
        /// <returns>Product category mapping</returns>
        public static ProductCategory GetProductCategoryById(int productCategoryId)
        {
            if (productCategoryId == 0)
            {
                return(null);
            }

            string key  = string.Format(PRODUCTCATEGORIES_BY_ID_KEY, productCategoryId);
            object obj2 = NopCache.Get(key);

            if (CategoryManager.MappingsCacheEnabled && (obj2 != null))
            {
                return((ProductCategory)obj2);
            }

            var dbItem = DBProviderManager <DBCategoryProvider> .Provider.GetProductCategoryById(productCategoryId);

            var productCategory = DBMapping(dbItem);

            if (CategoryManager.MappingsCacheEnabled)
            {
                NopCache.Max(key, productCategory);
            }
            return(productCategory);
        }
        /// <summary>
        /// Gets a product specification attribute mapping collection
        /// </summary>
        /// <param name="ProductID">Product identifier</param>
        /// <param name="AllowFiltering">0 to load attributes with AllowFiltering set to false, 0 to load attributes with AllowFiltering set to true, null to load all attributes</param>
        /// <param name="ShowOnProductPage">0 to load attributes with ShowOnProductPage set to false, 0 to load attributes with ShowOnProductPage set to true, null to load all attributes</param>
        /// <returns>Product specification attribute mapping collection</returns>
        public static ProductSpecificationAttributeCollection GetProductSpecificationAttributesByProductID(int ProductID, bool?AllowFiltering, bool?ShowOnProductPage)
        {
            string allowFilteringCacheStr = "null";

            if (AllowFiltering.HasValue)
            {
                allowFilteringCacheStr = AllowFiltering.ToString();
            }
            string showOnProductPageCacheStr = "null";

            if (ShowOnProductPage.HasValue)
            {
                showOnProductPageCacheStr = ShowOnProductPage.ToString();
            }
            string key  = string.Format(PRODUCTSPECIFICATIONATTRIBUTE_ALLBYPRODUCTID_KEY, ProductID, allowFilteringCacheStr, showOnProductPageCacheStr);
            object obj2 = NopCache.Get(key);

            if (SpecificationAttributeManager.CacheEnabled && (obj2 != null))
            {
                return((ProductSpecificationAttributeCollection)obj2);
            }

            DBProductSpecificationAttributeCollection dbCollection = DBProviderManager <DBSpecificationAttributeProvider> .Provider.GetProductSpecificationAttributesByProductID(ProductID, AllowFiltering, ShowOnProductPage);

            ProductSpecificationAttributeCollection productSpecificationAttributes = DBMapping(dbCollection);

            if (SpecificationAttributeManager.CacheEnabled)
            {
                NopCache.Max(key, productSpecificationAttributes);
            }
            return(productSpecificationAttributes);
        }
示例#21
0
        /// <summary>
        /// Gets a country
        /// </summary>
        /// <param name="CountryID">Country identifier</param>
        /// <returns>Country</returns>
        public static Country GetCountryByID(int CountryID)
        {
            if (CountryID == 0)
            {
                return(null);
            }

            string key  = string.Format(COUNTRIES_BY_ID_KEY, CountryID);
            object obj2 = NopCache.Get(key);

            if (CountryManager.CacheEnabled && (obj2 != null))
            {
                return((Country)obj2);
            }

            DBCountry dbItem = DBProviderManager <DBCountryProvider> .Provider.GetCountryByID(CountryID);

            Country country = DBMapping(dbItem);

            if (CountryManager.CacheEnabled)
            {
                NopCache.Max(key, country);
            }
            return(country);
        }
        /// <summary>
        /// Gets a checkout attribute value
        /// </summary>
        /// <param name="checkoutAttributeValueId">Checkout attribute value identifier</param>
        /// <param name="languageId">Language identifier</param>
        /// <returns>Checkout attribute value</returns>
        public static CheckoutAttributeValue GetCheckoutAttributeValueById(int checkoutAttributeValueId, int languageId)
        {
            if (checkoutAttributeValueId == 0)
            {
                return(null);
            }

            string key  = string.Format(CHECKOUTATTRIBUTEVALUES_BY_ID_KEY, checkoutAttributeValueId, languageId);
            object obj2 = NopCache.Get(key);

            if (CheckoutAttributeManager.CacheEnabled && (obj2 != null))
            {
                return((CheckoutAttributeValue)obj2);
            }

            var dbItem = DBProviderManager <DBCheckoutAttributeProvider> .Provider.GetCheckoutAttributeValueById(checkoutAttributeValueId, languageId);

            var checkoutAttributeValue = DBMapping(dbItem);

            if (CheckoutAttributeManager.CacheEnabled)
            {
                NopCache.Max(key, checkoutAttributeValue);
            }
            return(checkoutAttributeValue);
        }
        /// <summary>
        /// Gets a product manufacturer mapping
        /// </summary>
        /// <param name="ProductManufacturerID">Product manufacturer mapping identifier</param>
        /// <returns>Product manufacturer mapping</returns>
        public static ProductManufacturer GetProductManufacturerByID(int ProductManufacturerID)
        {
            if (ProductManufacturerID == 0)
            {
                return(null);
            }

            string key  = string.Format(PRODUCTMANUFACTURERS_BY_ID_KEY, ProductManufacturerID);
            object obj2 = NopCache.Get(key);

            if (ManufacturerManager.MappingsCacheEnabled && (obj2 != null))
            {
                return((ProductManufacturer)obj2);
            }

            DBProductManufacturer dbItem = DBProviderManager <DBManufacturerProvider> .Provider.GetProductManufacturerByID(ProductManufacturerID);

            ProductManufacturer productManufacturer = DBMapping(dbItem);

            if (ManufacturerManager.MappingsCacheEnabled)
            {
                NopCache.Max(key, productManufacturer);
            }
            return(productManufacturer);
        }
示例#24
0
        /// <summary>
        /// Gets a discount
        /// </summary>
        /// <param name="DiscountID">Discount identifier</param>
        /// <returns>Discount</returns>
        public static Discount GetDiscountByID(int DiscountID)
        {
            if (DiscountID == 0)
            {
                return(null);
            }

            string key  = string.Format(DISCOUNTS_BY_ID_KEY, DiscountID);
            object obj2 = NopCache.Get(key);

            if (DiscountManager.CacheEnabled && (obj2 != null))
            {
                return((Discount)obj2);
            }

            DBDiscount dbItem = DBProviderManager <DBDiscountProvider> .Provider.GetDiscountByID(DiscountID);

            Discount discount = DBMapping(dbItem);

            if (DiscountManager.CacheEnabled)
            {
                NopCache.Max(key, discount);
            }
            return(discount);
        }
示例#25
0
        /// <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);
            }

            var dbItem = DBProviderManager <DBStateProvinceProvider> .Provider.GetStateProvinceById(stateProvinceId);

            var stateProvince = DBMapping(dbItem);

            if (StateProvinceManager.CacheEnabled)
            {
                NopCache.Max(key, stateProvince);
            }
            return(stateProvince);
        }
示例#26
0
        /// <summary>
        /// Gets all discounts
        /// </summary>
        /// <param name="DiscountType">Discount type; null to load all discount</param>
        /// <returns>Discount collection</returns>
        public static DiscountCollection GetAllDiscounts(DiscountTypeEnum?DiscountType)
        {
            bool   showHidden = NopContext.Current.IsAdmin;
            string key        = string.Format(DISCOUNTS_ALL_KEY, showHidden, DiscountType);
            object obj2       = NopCache.Get(key);

            if (DiscountManager.CacheEnabled && (obj2 != null))
            {
                return((DiscountCollection)obj2);
            }

            int?discountTypeID = null;

            if (DiscountType.HasValue)
            {
                discountTypeID = (int)DiscountType.Value;
            }

            DBDiscountCollection dbCollection = DBProviderManager <DBDiscountProvider> .Provider.GetAllDiscounts(showHidden, discountTypeID);

            DiscountCollection discounts = DBMapping(dbCollection);

            if (DiscountManager.CacheEnabled)
            {
                NopCache.Max(key, discounts);
            }
            return(discounts);
        }
示例#27
0
        /// <summary>
        /// Gets a category template
        /// </summary>
        /// <param name="categoryTemplateId">Category template identifier</param>
        /// <returns>A category template</returns>
        public static CategoryTemplate GetCategoryTemplateById(int categoryTemplateId)
        {
            if (categoryTemplateId == 0)
            {
                return(null);
            }

            string key  = string.Format(CATEGORYTEMPLATES_BY_ID_KEY, categoryTemplateId);
            object obj2 = NopCache.Get(key);

            if (TemplateManager.CacheEnabled && (obj2 != null))
            {
                return((CategoryTemplate)obj2);
            }

            var dbItem = DBProviderManager <DBTemplateProvider> .Provider.GetCategoryTemplateById(categoryTemplateId);

            var categoryTemplate = DBMapping(dbItem);

            if (TemplateManager.CacheEnabled)
            {
                NopCache.Max(key, categoryTemplate);
            }
            return(categoryTemplate);
        }
示例#28
0
        /// <summary>
        /// Gets a language
        /// </summary>
        /// <param name="LanguageID">Language identifier</param>
        /// <returns>Language</returns>
        public static Language GetLanguageByID(int LanguageID)
        {
            if (LanguageID == 0)
            {
                return(null);
            }

            string key  = string.Format(LANGUAGES_BY_ID_KEY, LanguageID);
            object obj2 = NopCache.Get(key);

            if (LanguageManager.CacheEnabled && (obj2 != null))
            {
                return((Language)obj2);
            }

            DBLanguage dbItem = DBProviderManager <DBLanguageProvider> .Provider.GetLanguageByID(LanguageID);

            Language language = DBMapping(dbItem);

            if (LanguageManager.CacheEnabled)
            {
                NopCache.Max(key, language);
            }
            return(language);
        }
示例#29
0
        /// <summary>
        /// Gets a product template
        /// </summary>
        /// <param name="productTemplateId">Product template identifier</param>
        /// <returns>Product template</returns>
        public static ProductTemplate GetProductTemplateById(int productTemplateId)
        {
            if (productTemplateId == 0)
            {
                return(null);
            }

            string key  = string.Format(PRODUCTTEMPLATES_BY_ID_KEY, productTemplateId);
            object obj2 = NopCache.Get(key);

            if (TemplateManager.CacheEnabled && (obj2 != null))
            {
                return((ProductTemplate)obj2);
            }

            var dbItem = DBProviderManager <DBTemplateProvider> .Provider.GetProductTemplateById(productTemplateId);

            var productTemplate = DBMapping(dbItem);

            if (TemplateManager.CacheEnabled)
            {
                NopCache.Max(key, productTemplate);
            }
            return(productTemplate);
        }
示例#30
0
        /// <summary>
        /// Gets a tax category
        /// </summary>
        /// <param name="TaxCategoryID">Tax category identifier</param>
        /// <returns>Tax category</returns>
        public static TaxCategory GetTaxCategoryByID(int TaxCategoryID)
        {
            if (TaxCategoryID == 0)
            {
                return(null);
            }

            string key  = string.Format(TAXCATEGORIES_BY_ID_KEY, TaxCategoryID);
            object obj2 = NopCache.Get(key);

            if (TaxCategoryManager.CacheEnabled && (obj2 != null))
            {
                return((TaxCategory)obj2);
            }

            DBTaxCategory dbItem = DBProviderManager <DBTaxCategoryProvider> .Provider.GetTaxCategoryByID(TaxCategoryID);

            TaxCategory taxCategory = DBMapping(dbItem);

            if (TaxCategoryManager.CacheEnabled)
            {
                NopCache.Max(key, taxCategory);
            }
            return(taxCategory);
        }