Example #1
0
        /// <summary>
        /// Gets a specification attribute option
        /// </summary>
        /// <param name="specificationAttributeOptionId">The specification attribute option identifier</param>
        /// <param name="languageId">Language identifier</param>
        /// <returns>Specification attribute option</returns>
        public static SpecificationAttributeOption GetSpecificationAttributeOptionById(int specificationAttributeOptionId, int languageId)
        {
            if (specificationAttributeOptionId == 0)
            {
                return(null);
            }

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

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

            var dbItem = DBProviderManager <DBSpecificationAttributeProvider> .Provider.GetSpecificationAttributeOptionById(specificationAttributeOptionId, languageId);

            var specificationAttribute = DBMapping(dbItem);

            if (SpecificationAttributeManager.CacheEnabled)
            {
                NopCache.Max(key, specificationAttribute);
            }
            return(specificationAttribute);
        }
        /// <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;
            }

            var dbCollection = DBProviderManager <DBDiscountProvider> .Provider.GetAllDiscounts(showHidden, discountTypeId);

            var discounts = DBMapping(dbCollection);

            if (DiscountManager.CacheEnabled)
            {
                NopCache.Max(key, discounts);
            }
            return(discounts);
        }
        /// <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);
            }

            DBMeasureDimension dbItem = DBProviderManager <DBMeasureProvider> .Provider.GetMeasureDimensionByID(MeasureDimensionID);

            MeasureDimension measureDimension = DBMapping(dbItem);

            if (MeasureManager.CacheEnabled)
            {
                NopCache.Max(key, measureDimension);
            }
            return(measureDimension);
        }
        /// <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);
            }

            DBCategoryTemplate dbItem = DBProviderManager <DBTemplateProvider> .Provider.GetCategoryTemplateByID(CategoryTemplateID);

            CategoryTemplate categoryTemplate = DBMapping(dbItem);

            if (TemplateManager.CacheEnabled)
            {
                NopCache.Max(key, categoryTemplate);
            }
            return(categoryTemplate);
        }
        /// <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);
            }

            DBProductTemplate dbItem = DBProviderManager <DBTemplateProvider> .Provider.GetProductTemplateByID(ProductTemplateID);

            ProductTemplate productTemplate = DBMapping(dbItem);

            if (TemplateManager.CacheEnabled)
            {
                NopCache.Max(key, productTemplate);
            }
            return(productTemplate);
        }
Example #6
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);
            }

            var dbItem = DBProviderManager <DBCreditCardTypeProvider> .Provider.GetCreditCardTypeById(creditCardTypeId);

            var creditCardType = DBMapping(dbItem);

            if (CreditCardTypeManager.CacheEnabled)
            {
                NopCache.Max(key, creditCardType);
            }
            return(creditCardType);
        }
        /// <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);
        }
Example #8
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);
            }

            var dbItem = DBProviderManager <DBPollProvider> .Provider.GetPollById(pollId);

            var poll = DBMapping(dbItem);

            if (PollManager.CacheEnabled)
            {
                NopCache.Max(key, poll);
            }
            return(poll);
        }
        /// <summary>
        /// Gets a tax provider
        /// </summary>
        /// <param name="TaxProviderID">Tax provider identifier</param>
        /// <returns>Tax provider</returns>
        public static TaxProvider GetTaxProviderByID(int TaxProviderID)
        {
            if (TaxProviderID == 0)
            {
                return(null);
            }

            string key  = string.Format(TAXPROVIDERS_BY_ID_KEY, TaxProviderID);
            object obj2 = NopCache.Get(key);

            if (TaxProviderManager.CacheEnabled && (obj2 != null))
            {
                return((TaxProvider)obj2);
            }

            DBTaxProvider dbItem = DBProviderManager <DBTaxProviderProvider> .Provider.GetTaxProviderByID(TaxProviderID);

            TaxProvider taxProvider = DBMapping(dbItem);

            if (TaxProviderManager.CacheEnabled)
            {
                NopCache.Max(key, taxProvider);
            }
            return(taxProvider);
        }
Example #10
0
        /// <summary>
        /// Gets a payment method
        /// </summary>
        /// <param name="paymentMethodId">Payment method identifier</param>
        /// <returns>Payment method</returns>
        public static PaymentMethod GetPaymentMethodById(int paymentMethodId)
        {
            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);
        }
Example #11
0
        /// <summary>
        /// Gets a product variant attribute mapping
        /// </summary>
        /// <param name="productVariantAttributeId">Product variant attribute mapping identifier</param>
        /// <returns>Product variant attribute mapping</returns>
        public static ProductVariantAttribute GetProductVariantAttributeById(int productVariantAttributeId)
        {
            if (productVariantAttributeId == 0)
            {
                return(null);
            }

            string key  = string.Format(PRODUCTVARIANTATTRIBUTES_BY_ID_KEY, productVariantAttributeId);
            object obj2 = NopCache.Get(key);

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

            var dbItem = DBProviderManager <DBProductAttributeProvider> .Provider.GetProductVariantAttributeById(productVariantAttributeId);

            var productVariantAttribute = DBMapping(dbItem);

            if (ProductAttributeManager.CacheEnabled)
            {
                NopCache.Max(key, productVariantAttribute);
            }
            return(productVariantAttribute);
        }
Example #12
0
        /// <summary>
        /// Gets a shipping status by identifier
        /// </summary>
        /// <param name="shippingStatusId">Shipping status identifier</param>
        /// <returns>Shipping status</returns>
        public static ShippingStatus GetShippingStatusById(int shippingStatusId)
        {
            if (shippingStatusId == 0)
            {
                return(null);
            }

            string key  = string.Format(SHIPPINGTATUSES_BY_ID_KEY, shippingStatusId);
            object obj2 = NopCache.Get(key);

            if (ShippingStatusManager.CacheEnabled && (obj2 != null))
            {
                return((ShippingStatus)obj2);
            }

            var dbItem = DBProviderManager <DBShippingStatusProvider> .Provider.GetShippingStatusById(shippingStatusId);

            var shippingStatus = DBMapping(dbItem);

            if (ShippingStatusManager.CacheEnabled)
            {
                NopCache.Max(key, shippingStatus);
            }
            return(shippingStatus);
        }
Example #13
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);
            }

            var dbItem = DBProviderManager <DBNewsProvider> .Provider.GetNewsById(newsId);

            var news = DBMapping(dbItem);

            if (NewsManager.CacheEnabled)
            {
                NopCache.Max(key, news);
            }
            return(news);
        }
Example #14
0
        /// <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);
            }

            var dbCollection = DBProviderManager <DBSpecificationAttributeProvider> .Provider.GetProductSpecificationAttributesByProductId(productId,
                                                                                                                                           allowFiltering, showOnProductPage);

            var productSpecificationAttributes = DBMapping(dbCollection);

            if (SpecificationAttributeManager.CacheEnabled)
            {
                NopCache.Max(key, productSpecificationAttributes);
            }
            return(productSpecificationAttributes);
        }
        /// <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);
        }
Example #16
0
        /// <summary>
        /// Gets an blog post
        /// </summary>
        /// <param name="blogPostId">Blog post identifier</param>
        /// <returns>Blog post</returns>
        public static BlogPost GetBlogPostById(int blogPostId)
        {
            if (blogPostId == 0)
            {
                return(null);
            }

            string key  = string.Format(BLOGPOST_BY_ID_KEY, blogPostId);
            object obj2 = NopCache.Get(key);

            if (BlogManager.CacheEnabled && (obj2 != null))
            {
                return((BlogPost)obj2);
            }

            var dbItem = DBProviderManager <DBBlogProvider> .Provider.GetBlogPostById(blogPostId);

            var blogPost = DBMapping(dbItem);

            if (BlogManager.CacheEnabled)
            {
                NopCache.Max(key, blogPost);
            }
            return(blogPost);
        }
        /// <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);
        }
Example #18
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);
        }
Example #19
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 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);
        }
Example #21
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 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);
            }

            var dbItem = DBProviderManager <DBDiscountProvider> .Provider.GetDiscountById(discountId);

            var discount = DBMapping(dbItem);

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

            DBManufacturerTemplate dbItem = DBProviderManager <DBTemplateProvider> .Provider.GetManufacturerTemplateByID(ManufacturerTemplateID);

            ManufacturerTemplate manufacturerTemplate = DBMapping(dbItem);

            if (TemplateManager.CacheEnabled)
            {
                NopCache.Max(key, manufacturerTemplate);
            }
            return(manufacturerTemplate);
        }
        /// <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);
            }

            DBMeasureWeight dbItem = DBProviderManager <DBMeasureProvider> .Provider.GetMeasureWeightByID(MeasureWeightID);

            MeasureWeight measureWeight = DBMapping(dbItem);

            if (MeasureManager.CacheEnabled)
            {
                NopCache.Max(key, measureWeight);
            }
            return(measureWeight);
        }
        /// <summary>
        /// Gets a manufacturer
        /// </summary>
        /// <param name="manufacturerId">Manufacturer identifier</param>
        /// <param name="languageId">Language identifier</param>
        /// <returns>Manufacturer</returns>
        public static Manufacturer GetManufacturerById(int manufacturerId, int languageId)
        {
            if (manufacturerId == 0)
            {
                return(null);
            }

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

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

            var dbItem = DBProviderManager <DBManufacturerProvider> .Provider.GetManufacturerById(manufacturerId, languageId);

            var manufacturer = DBMapping(dbItem);

            if (ManufacturerManager.ManufacturersCacheEnabled)
            {
                NopCache.Max(key, manufacturer);
            }
            return(manufacturer);
        }
Example #26
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);
            }

            var dbItem = DBProviderManager <DBCountryProvider> .Provider.GetCountryById(countryId);

            var country = DBMapping(dbItem);

            if (CountryManager.CacheEnabled)
            {
                NopCache.Max(key, country);
            }
            return(country);
        }
        /// <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);
            }

            var dbItem = DBProviderManager <DBLanguageProvider> .Provider.GetLanguageById(languageId);

            var language = DBMapping(dbItem);

            if (LanguageManager.CacheEnabled)
            {
                NopCache.Max(key, language);
            }
            return(language);
        }
Example #28
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);
        }
Example #29
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 all activity log type items
        /// </summary>
        /// <returns>Activity log type collection</returns>
        public static ActivityLogTypeCollection GetAllActivityTypes()
        {
            if (NopCache.IsEnabled)
            {
                object cache = NopCache.Get(ACTIVITYTYPE_ALL_KEY);
                if (cache != null)
                    return (ActivityLogTypeCollection)cache;
            }

            var dbCollection = DBProviderManager<DBCustomerActivityProvider>.Provider.GetAllActivityTypes();
            var collection = DBMapping(dbCollection);

            if (NopCache.IsEnabled)
                NopCache.Max(ACTIVITYTYPE_ALL_KEY, collection);
            
            return collection;
        }