Example #1
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 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);
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
        /// <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);
        }
        /// <summary>
        /// Updates the manufacturer
        /// </summary>
        /// <param name="manufacturerId">Manufacturer identifier</param>
        /// <param name="name">The name</param>
        /// <param name="description">The description</param>
        /// <param name="templateId">The template identifier</param>
        /// <param name="metaKeywords">The meta keywords</param>
        /// <param name="metaDescription">The meta description</param>
        /// <param name="metaTitle">The meta title</param>
        /// <param name="seName">The search-engine name</param>
        /// <param name="pictureId">The parent picture identifier</param>
        /// <param name="pageSize">The page size</param>
        /// <param name="priceRanges">The price ranges</param>
        /// <param name="published">A value indicating whether the entity is published</param>
        /// <param name="deleted">A value indicating whether the entity has been deleted</param>
        /// <param name="displayOrder">The display order</param>
        /// <param name="createdOn">The date and time of instance creation</param>
        /// <param name="updatedOn">The date and time of instance update</param>
        /// <returns>Manufacturer</returns>
        public static Manufacturer UpdateManufacturer(int manufacturerId,
                                                      string name, string description,
                                                      int templateId, string metaKeywords, string metaDescription, string metaTitle,
                                                      string seName, int pictureId, int pageSize, string priceRanges,
                                                      bool published, bool deleted, int displayOrder,
                                                      DateTime createdOn, DateTime updatedOn)
        {
            createdOn = DateTimeHelper.ConvertToUtcTime(createdOn);
            updatedOn = DateTimeHelper.ConvertToUtcTime(updatedOn);

            var dbItem = DBProviderManager <DBManufacturerProvider> .Provider.UpdateManufacturer(manufacturerId,
                                                                                                 name, description, templateId, metaKeywords, metaDescription, metaTitle,
                                                                                                 seName, pictureId, pageSize, priceRanges, published, deleted,
                                                                                                 displayOrder, createdOn, updatedOn);

            var manufacturer = DBMapping(dbItem);

            if (ManufacturerManager.ManufacturersCacheEnabled || ManufacturerManager.MappingsCacheEnabled)
            {
                NopCache.RemoveByPattern(MANUFACTURERS_PATTERN_KEY);
                NopCache.RemoveByPattern(PRODUCTMANUFACTURERS_PATTERN_KEY);
            }

            return(manufacturer);
        }
        /// <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);
        }
 /// <summary>
 /// Deletes an activity log type item
 /// </summary>
 /// <param name="activityLogTypeId">Activity log type identifier</param>
 public static void DeleteActivityType(int activityLogTypeId)
 {
     if (NopCache.IsEnabled)
         NopCache.RemoveByPattern(ACTIVITYTYPE_PATTERN_KEY);
     
     DBProviderManager<DBCustomerActivityProvider>.Provider.DeleteActivityType(activityLogTypeId);
 }
Example #13
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);
        }
Example #14
0
        /// <summary>
        /// Updates the tax rate
        /// </summary>
        /// <param name="taxRateId">The tax rate identifier</param>
        /// <param name="taxCategoryId">The tax category identifier</param>
        /// <param name="countryId">The country identifier</param>
        /// <param name="stateProvinceId">The state/province identifier</param>
        /// <param name="zip">The zip</param>
        /// <param name="percentage">The percentage</param>
        /// <returns>Tax rate</returns>
        public static TaxRate UpdateTaxRate(int taxRateId,
                                            int taxCategoryId, int countryId, int stateProvinceId,
                                            string zip, decimal percentage)
        {
            if (zip == null)
            {
                zip = string.Empty;
            }
            if (!String.IsNullOrEmpty(zip))
            {
                zip = zip.Trim();
            }

            var dbItem = DBProviderManager <DBTaxRateProvider> .Provider.UpdateTaxRate(taxRateId,
                                                                                       taxCategoryId, countryId, stateProvinceId, zip, percentage);

            var taxRate = DBMapping(dbItem);

            if (TaxRateManager.CacheEnabled)
            {
                NopCache.RemoveByPattern(TAXRATE_PATTERN_KEY);
            }

            return(taxRate);
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
        /// <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);
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
        /// <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);
        }