/// <summary>
        /// Update a localized manufacturer
        /// </summary>
        /// <param name="manufacturerLocalized">Manufacturer content</param>
        public void UpdateManufacturerLocalized(ManufacturerLocalized manufacturerLocalized)
        {
            if (manufacturerLocalized == null)
            {
                throw new ArgumentNullException("manufacturerLocalized");
            }

            manufacturerLocalized.Name            = CommonHelper.EnsureNotNull(manufacturerLocalized.Name);
            manufacturerLocalized.Name            = CommonHelper.EnsureMaximumLength(manufacturerLocalized.Name, 400);
            manufacturerLocalized.Description     = CommonHelper.EnsureNotNull(manufacturerLocalized.Description);
            manufacturerLocalized.MetaKeywords    = CommonHelper.EnsureNotNull(manufacturerLocalized.MetaKeywords);
            manufacturerLocalized.MetaKeywords    = CommonHelper.EnsureMaximumLength(manufacturerLocalized.MetaKeywords, 400);
            manufacturerLocalized.MetaDescription = CommonHelper.EnsureNotNull(manufacturerLocalized.MetaDescription);
            manufacturerLocalized.MetaDescription = CommonHelper.EnsureMaximumLength(manufacturerLocalized.MetaDescription, 4000);
            manufacturerLocalized.MetaTitle       = CommonHelper.EnsureNotNull(manufacturerLocalized.MetaTitle);
            manufacturerLocalized.MetaTitle       = CommonHelper.EnsureMaximumLength(manufacturerLocalized.MetaTitle, 400);
            manufacturerLocalized.SEName          = CommonHelper.EnsureNotNull(manufacturerLocalized.SEName);
            manufacturerLocalized.SEName          = CommonHelper.EnsureMaximumLength(manufacturerLocalized.SEName, 100);

            bool allFieldsAreEmpty = string.IsNullOrEmpty(manufacturerLocalized.Name) &&
                                     string.IsNullOrEmpty(manufacturerLocalized.Description) &&
                                     string.IsNullOrEmpty(manufacturerLocalized.MetaKeywords) &&
                                     string.IsNullOrEmpty(manufacturerLocalized.MetaDescription) &&
                                     string.IsNullOrEmpty(manufacturerLocalized.MetaTitle) &&
                                     string.IsNullOrEmpty(manufacturerLocalized.SEName);


            if (!_context.IsAttached(manufacturerLocalized))
            {
                _context.ManufacturerLocalized.Attach(manufacturerLocalized);
            }

            if (allFieldsAreEmpty)
            {
                //delete if all fields are empty
                _context.DeleteObject(manufacturerLocalized);
                _context.SaveChanges();
            }
            else
            {
                _context.SaveChanges();
            }

            if (this.ManufacturersCacheEnabled)
            {
                _cacheManager.RemoveByPattern(MANUFACTURERS_PATTERN_KEY);
            }
        }
示例#2
0
        /// <summary>
        /// Update a localized category
        /// </summary>
        /// <param name="categoryLocalized">Localized category</param>
        public void UpdateCategoryLocalized(CategoryLocalized categoryLocalized)
        {
            if (categoryLocalized == null)
            {
                throw new ArgumentNullException("categoryLocalized");
            }

            categoryLocalized.Name            = CommonHelper.EnsureNotNull(categoryLocalized.Name);
            categoryLocalized.Name            = CommonHelper.EnsureMaximumLength(categoryLocalized.Name, 400);
            categoryLocalized.Description     = CommonHelper.EnsureNotNull(categoryLocalized.Description);
            categoryLocalized.MetaKeywords    = CommonHelper.EnsureNotNull(categoryLocalized.MetaKeywords);
            categoryLocalized.MetaKeywords    = CommonHelper.EnsureMaximumLength(categoryLocalized.MetaKeywords, 400);
            categoryLocalized.MetaDescription = CommonHelper.EnsureNotNull(categoryLocalized.MetaDescription);
            categoryLocalized.MetaDescription = CommonHelper.EnsureMaximumLength(categoryLocalized.MetaDescription, 4000);
            categoryLocalized.MetaTitle       = CommonHelper.EnsureNotNull(categoryLocalized.MetaTitle);
            categoryLocalized.MetaTitle       = CommonHelper.EnsureMaximumLength(categoryLocalized.MetaTitle, 400);
            categoryLocalized.SEName          = CommonHelper.EnsureNotNull(categoryLocalized.SEName);
            categoryLocalized.SEName          = CommonHelper.EnsureMaximumLength(categoryLocalized.SEName, 100);

            bool allFieldsAreEmpty = string.IsNullOrEmpty(categoryLocalized.Name) &&
                                     string.IsNullOrEmpty(categoryLocalized.Description) &&
                                     string.IsNullOrEmpty(categoryLocalized.MetaKeywords) &&
                                     string.IsNullOrEmpty(categoryLocalized.MetaDescription) &&
                                     string.IsNullOrEmpty(categoryLocalized.MetaTitle) &&
                                     string.IsNullOrEmpty(categoryLocalized.SEName);


            if (!_context.IsAttached(categoryLocalized))
            {
                _context.CategoryLocalized.Attach(categoryLocalized);
            }

            if (allFieldsAreEmpty)
            {
                //delete if all fields are empty
                _context.DeleteObject(categoryLocalized);
                _context.SaveChanges();
            }
            else
            {
                _context.SaveChanges();
            }

            if (this.CategoriesCacheEnabled)
            {
                _cacheManager.RemoveByPattern(CATEGORIES_PATTERN_KEY);
            }
        }
        /// <summary>
        /// Deletes a picture
        /// </summary>
        /// <param name="pictureId">Picture identifier</param>
        public void DeletePicture(int pictureId)
        {
            var picture = GetPictureById(pictureId);

            if (picture == null)
            {
                return;
            }

            //delete thumbs
            string filter = string.Format("{0}*.*", pictureId.ToString("0000000"));

            string[] currentFiles = System.IO.Directory.GetFiles(this.LocalThumbImagePath, filter);
            foreach (string currentFileName in currentFiles)
            {
                File.Delete(Path.Combine(this.LocalThumbImagePath, currentFileName));
            }

            //delete from file system
            if (!this.StoreInDB)
            {
                DeletePictureOnFileSystem(picture);
            }

            //delete from database

            if (!_context.IsAttached(picture))
            {
                _context.Pictures.Attach(picture);
            }
            _context.DeleteObject(picture);
            _context.SaveChanges();
        }
        /// <summary>
        /// Deletes a log item
        /// </summary>
        /// <param name="logId">Log item identifier</param>
        public void DeleteLog(int logId)
        {
            var log = GetLogById(logId);

            if (log == null)
            {
                return;
            }


            if (!_context.IsAttached(log))
            {
                _context.Log.Attach(log);
            }
            _context.DeleteObject(log);
            _context.SaveChanges();
        }
        /// <summary>
        /// Deletes a topic
        /// </summary>
        /// <param name="topicId">Topic identifier</param>
        public void DeleteTopic(int topicId)
        {
            var topic = GetTopicById(topicId);

            if (topic == null)
            {
                return;
            }


            if (!_context.IsAttached(topic))
            {
                _context.Topics.Attach(topic);
            }
            _context.DeleteObject(topic);
            _context.SaveChanges();
        }
示例#6
0
        /// <summary>
        /// Clear search log
        /// </summary>
        public void ClearSearchLog()
        {
            var log = _context.SearchLog.ToList();

            foreach (var logItem in log)
            {
                _context.DeleteObject(logItem);
            }
            _context.SaveChanges();
        }
示例#7
0
        /// <summary>
        /// Deletes measure dimension
        /// </summary>
        /// <param name="measureDimensionId">Measure dimension identifier</param>
        public void DeleteMeasureDimension(int measureDimensionId)
        {
            var measureDimension = GetMeasureDimensionById(measureDimensionId);

            if (measureDimension == null)
            {
                return;
            }


            if (!_context.IsAttached(measureDimension))
            {
                _context.MeasureDimensions.Attach(measureDimension);
            }
            _context.DeleteObject(measureDimension);
            _context.SaveChanges();
            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(MEASUREDIMENSIONS_PATTERN_KEY);
            }
        }
示例#8
0
        /// <summary>
        /// Deletes a category template
        /// </summary>
        /// <param name="categoryTemplateId">Category template identifier</param>
        public void DeleteCategoryTemplate(int categoryTemplateId)
        {
            var categoryTemplate = GetCategoryTemplateById(categoryTemplateId);

            if (categoryTemplate == null)
            {
                return;
            }


            if (!_context.IsAttached(categoryTemplate))
            {
                _context.CategoryTemplates.Attach(categoryTemplate);
            }
            _context.DeleteObject(categoryTemplate);
            _context.SaveChanges();

            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(CATEGORYTEMPLATES_PATTERN_KEY);
            }
        }
        /// <summary>
        /// Deletes an activity log type item
        /// </summary>
        /// <param name="activityLogTypeId">Activity log type identifier</param>
        public void DeleteActivityType(int activityLogTypeId)
        {
            var activityLogType = GetActivityTypeById(activityLogTypeId);

            if (activityLogType == null)
            {
                return;
            }


            if (!_context.IsAttached(activityLogType))
            {
                _context.ActivityLogTypes.Attach(activityLogType);
            }
            _context.DeleteObject(activityLogType);
            _context.SaveChanges();

            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(ACTIVITYTYPE_PATTERN_KEY);
            }
        }
        /// <summary>
        /// Deletes a shipping rate computation method
        /// </summary>
        /// <param name="shippingRateComputationMethodId">Shipping rate computation method identifier</param>
        public void DeleteShippingRateComputationMethod(int shippingRateComputationMethodId)
        {
            var shippingRateComputationMethod = GetShippingRateComputationMethodById(shippingRateComputationMethodId);

            if (shippingRateComputationMethod == null)
            {
                return;
            }


            if (!_context.IsAttached(shippingRateComputationMethod))
            {
                _context.ShippingRateComputationMethods.Attach(shippingRateComputationMethod);
            }
            _context.DeleteObject(shippingRateComputationMethod);
            _context.SaveChanges();

            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(SHIPPINGRATECOMPUTATIONMETHODS_PATTERN_KEY);
            }
        }
示例#11
0
        /// <summary>
        /// Deletes a news
        /// </summary>
        /// <param name="newsId">The news identifier</param>
        public void DeleteNews(int newsId)
        {
            var news = GetNewsById(newsId);

            if (news == null)
            {
                return;
            }


            if (!_context.IsAttached(news))
            {
                _context.News.Attach(news);
            }
            _context.DeleteObject(news);
            _context.SaveChanges();

            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(NEWS_PATTERN_KEY);
            }
        }
示例#12
0
        /// <summary>
        /// Deletes a customer action
        /// </summary>
        /// <param name="customerActionId">Customer action identifier</param>
        public void DeleteCustomerAction(int customerActionId)
        {
            var customerAction = GetCustomerActionById(customerActionId);

            if (customerAction == null)
            {
                return;
            }


            if (!_context.IsAttached(customerAction))
            {
                _context.CustomerActions.Attach(customerAction);
            }
            _context.DeleteObject(customerAction);
            _context.SaveChanges();

            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(CUSTOMERACTIONS_PATTERN_KEY);
            }
        }
        /// <summary>
        /// Deletes an blog post
        /// </summary>
        /// <param name="blogPostId">Blog post identifier</param>
        public void DeleteBlogPost(int blogPostId)
        {
            var blogPost = GetBlogPostById(blogPostId);

            if (blogPost == null)
            {
                return;
            }


            if (!_context.IsAttached(blogPost))
            {
                _context.BlogPosts.Attach(blogPost);
            }
            _context.DeleteObject(blogPost);
            _context.SaveChanges();

            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(BLOGPOST_PATTERN_KEY);
            }
        }
        /// <summary>
        /// Deletes an IP address by its identifier
        /// </summary>
        /// <param name="ipAddressId">IP address unique identifier</param>
        public void DeleteBannedIpAddress(int ipAddressId)
        {
            var ipAddress = GetBannedIpAddressById(ipAddressId);

            if (ipAddress == null)
            {
                return;
            }


            if (!_context.IsAttached(ipAddress))
            {
                _context.BannedIpAddresses.Attach(ipAddress);
            }
            _context.DeleteObject(ipAddress);
            _context.SaveChanges();

            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(BLACKLIST_IP_PATTERN_KEY);
            }
        }
        /// <summary>
        /// Deletes a checkout attribute
        /// </summary>
        /// <param name="checkoutAttributeId">Checkout attribute identifier</param>
        public void DeleteCheckoutAttribute(int checkoutAttributeId)
        {
            var checkoutAttribute = GetCheckoutAttributeById(checkoutAttributeId);

            if (checkoutAttribute == null)
            {
                return;
            }


            if (!_context.IsAttached(checkoutAttribute))
            {
                _context.CheckoutAttributes.Attach(checkoutAttribute);
            }
            _context.DeleteObject(checkoutAttribute);
            _context.SaveChanges();

            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(CHECKOUTATTRIBUTES_PATTERN_KEY);
                _cacheManager.RemoveByPattern(CHECKOUTATTRIBUTEVALUES_PATTERN_KEY);
            }
        }
        /// <summary>
        /// Deletes a poll
        /// </summary>
        /// <param name="pollId">The poll identifier</param>
        public void DeletePoll(int pollId)
        {
            var poll = GetPollById(pollId);

            if (poll == null)
            {
                return;
            }


            if (!_context.IsAttached(poll))
            {
                _context.Polls.Attach(poll);
            }
            _context.DeleteObject(poll);
            _context.SaveChanges();

            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(POLLS_PATTERN_KEY);
                _cacheManager.RemoveByPattern(POLLANSWERS_PATTERN_KEY);
            }
        }
示例#17
0
        /// <summary>
        /// Deletes a specification attribute
        /// </summary>
        /// <param name="specificationAttributeId">The specification attribute identifier</param>
        public void DeleteSpecificationAttribute(int specificationAttributeId)
        {
            var specificationAttribute = GetSpecificationAttributeById(specificationAttributeId);

            if (specificationAttribute == null)
            {
                return;
            }


            if (!_context.IsAttached(specificationAttribute))
            {
                _context.SpecificationAttributes.Attach(specificationAttribute);
            }
            _context.DeleteObject(specificationAttribute);
            _context.SaveChanges();

            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(SPECIFICATIONATTRIBUTE_PATTERN_KEY);
                _cacheManager.RemoveByPattern(SPECIFICATIONATTRIBUTEOPTION_PATTERN_KEY);
                _cacheManager.RemoveByPattern(PRODUCTSPECIFICATIONATTRIBUTE_PATTERN_KEY);
            }
        }
        /// <summary>
        /// Deletes a ShippingByTotal
        /// </summary>
        /// <param name="shippingByTotalId">ShippingByTotal identifier</param>
        public void DeleteShippingByTotal(int shippingByTotalId)
        {
            var shippingByTotal = GetById(shippingByTotalId);

            if (shippingByTotal == null)
            {
                return;
            }


            if (!_context.IsAttached(shippingByTotal))
            {
                _context.ShippingByTotal.Attach(shippingByTotal);
            }
            _context.DeleteObject(shippingByTotal);
            _context.SaveChanges();
        }
        /// <summary>
        /// Deletes a discount usage history entry
        /// </summary>
        /// <param name="discountUsageHistoryId">Discount usage history entry identifier</param>
        public void DeleteDiscountUsageHistory(int discountUsageHistoryId)
        {
            var discountUsageHistory = GetDiscountUsageHistoryById(discountUsageHistoryId);

            if (discountUsageHistory == null)
            {
                return;
            }


            if (!_context.IsAttached(discountUsageHistory))
            {
                _context.DiscountUsageHistory.Attach(discountUsageHistory);
            }
            _context.DeleteObject(discountUsageHistory);
            _context.SaveChanges();
        }
        /// <summary>
        /// Deletes a download
        /// </summary>
        /// <param name="downloadId">Download identifier</param>
        public void DeleteDownload(int downloadId)
        {
            var download = GetDownloadById(downloadId);

            if (download == null)
            {
                return;
            }


            if (!_context.IsAttached(download))
            {
                _context.Downloads.Attach(download);
            }
            _context.DeleteObject(download);
            _context.SaveChanges();
        }
示例#21
0
        /// <summary>
        /// Deletes a campaign
        /// </summary>
        /// <param name="campaignId">Campaign identifier</param>
        public void DeleteCampaign(int campaignId)
        {
            var campaign = GetCampaignById(campaignId);

            if (campaign == null)
            {
                return;
            }


            if (!_context.IsAttached(campaign))
            {
                _context.Campaigns.Attach(campaign);
            }
            _context.DeleteObject(campaign);
            _context.SaveChanges();
        }
        /// <summary>
        /// Deletes a ShippingByWeight
        /// </summary>
        /// <param name="shippingByWeightId">ShippingByWeight identifier</param>
        public void DeleteShippingByWeight(int shippingByWeightId)
        {
            var shippingByWeight = GetById(shippingByWeightId);

            if (shippingByWeight == null)
            {
                return;
            }


            if (!_context.IsAttached(shippingByWeight))
            {
                _context.ShippingByWeight.Attach(shippingByWeight);
            }
            _context.DeleteObject(shippingByWeight);
            _context.SaveChanges();
        }
示例#23
0
        /// <summary>
        /// Deletes a ShippingByWeightAndCountry
        /// </summary>
        /// <param name="shippingByWeightAndCountryId">ShippingByWeightAndCountry identifier</param>
        public void DeleteShippingByWeightAndCountry(int shippingByWeightAndCountryId)
        {
            var shippingByWeightAndCountry = GetById(shippingByWeightAndCountryId);

            if (shippingByWeightAndCountry == null)
            {
                return;
            }


            if (!_context.IsAttached(shippingByWeightAndCountry))
            {
                _context.ShippingByWeightAndCountry.Attach(shippingByWeightAndCountry);
            }
            _context.DeleteObject(shippingByWeightAndCountry);
            _context.SaveChanges();
        }
        /// <summary>
        /// Deletes a tax provider
        /// </summary>
        /// <param name="taxProviderId">Tax provider identifier</param>
        public void DeleteTaxProvider(int taxProviderId)
        {
            var taxProvider = GetTaxProviderById(taxProviderId);

            if (taxProvider == null)
            {
                return;
            }


            if (!_context.IsAttached(taxProvider))
            {
                _context.TaxProviders.Attach(taxProvider);
            }
            _context.DeleteObject(taxProvider);
            _context.SaveChanges();
            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(TAXPROVIDERS_PATTERN_KEY);
            }
        }
示例#25
0
        /// <summary>
        /// Deletes a country
        /// </summary>
        /// <param name="countryId">Country identifier</param>
        public void DeleteCountry(int countryId)
        {
            var country = GetCountryById(countryId);

            if (country == null)
            {
                return;
            }


            if (!_context.IsAttached(country))
            {
                _context.Countries.Attach(country);
            }
            _context.DeleteObject(country);
            _context.SaveChanges();

            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(COUNTRIES_PATTERN_KEY);
            }
        }
示例#26
0
        /// <summary>
        /// Deletes a tax category
        /// </summary>
        /// <param name="taxCategoryId">The tax category identifier</param>
        public void DeleteTaxCategory(int taxCategoryId)
        {
            var taxCategory = GetTaxCategoryById(taxCategoryId);

            if (taxCategory == null)
            {
                return;
            }


            if (!_context.IsAttached(taxCategory))
            {
                _context.TaxCategories.Attach(taxCategory);
            }
            _context.DeleteObject(taxCategory);
            _context.SaveChanges();

            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(TAXCATEGORIES_PATTERN_KEY);
            }
        }
        /// <summary>
        /// Deletes currency
        /// </summary>
        /// <param name="currencyId">Currency identifier</param>
        public void DeleteCurrency(int currencyId)
        {
            var currency = GetCurrencyById(currencyId);

            if (currency == null)
            {
                return;
            }


            if (!_context.IsAttached(currency))
            {
                _context.Currencies.Attach(currency);
            }
            _context.DeleteObject(currency);
            _context.SaveChanges();

            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(CURRENCIES_PATTERN_KEY);
            }
        }
        /// <summary>
        /// Deletes a payment method
        /// </summary>
        /// <param name="paymentMethodId">Payment method identifier</param>
        public void DeletePaymentMethod(int paymentMethodId)
        {
            var paymentMethod = GetPaymentMethodById(paymentMethodId);

            if (paymentMethod == null)
            {
                return;
            }


            if (!_context.IsAttached(paymentMethod))
            {
                _context.PaymentMethods.Attach(paymentMethod);
            }
            _context.DeleteObject(paymentMethod);
            _context.SaveChanges();

            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(PAYMENTMETHODS_PATTERN_KEY);
            }
        }
示例#29
0
        /// <summary>
        /// Deletes a setting
        /// </summary>
        /// <param name="settingId">Setting identifer</param>
        public void DeleteSetting(int settingId)
        {
            var setting = GetSettingById(settingId);

            if (setting == null)
            {
                return;
            }


            if (!_context.IsAttached(setting))
            {
                _context.Settings.Attach(setting);
            }
            _context.DeleteObject(setting);
            _context.SaveChanges();

            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(SETTINGS_ALL_KEY);
            }
        }
        /// <summary>
        /// Deletes a locale string resource
        /// </summary>
        /// <param name="localeStringResourceId">Locale string resource identifier</param>
        public void DeleteLocaleStringResource(int localeStringResourceId)
        {
            var localeStringResource = GetLocaleStringResourceById(localeStringResourceId);

            if (localeStringResource == null)
            {
                return;
            }


            if (!_context.IsAttached(localeStringResource))
            {
                _context.LocaleStringResources.Attach(localeStringResource);
            }
            _context.DeleteObject(localeStringResource);
            _context.SaveChanges();

            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(LOCALSTRINGRESOURCES_PATTERN_KEY);
            }
        }