コード例 #1
0
        /// <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();
        }
コード例 #2
0
        /// <summary>
        /// Inserts a warehouse
        /// </summary>
        /// <param name="warehouse">Warehouse</param>
        public void InsertWarehouse(Warehouse warehouse)
        {
            if (warehouse == null)
            {
                throw new ArgumentNullException("warehouse");
            }

            warehouse.Name          = CommonHelper.EnsureNotNull(warehouse.Name);
            warehouse.Name          = CommonHelper.EnsureMaximumLength(warehouse.Name, 255);
            warehouse.PhoneNumber   = CommonHelper.EnsureNotNull(warehouse.PhoneNumber);
            warehouse.PhoneNumber   = CommonHelper.EnsureMaximumLength(warehouse.PhoneNumber, 50);
            warehouse.Email         = CommonHelper.EnsureNotNull(warehouse.Email);
            warehouse.Email         = CommonHelper.EnsureMaximumLength(warehouse.Email, 255);
            warehouse.FaxNumber     = CommonHelper.EnsureNotNull(warehouse.FaxNumber);
            warehouse.FaxNumber     = CommonHelper.EnsureMaximumLength(warehouse.FaxNumber, 50);
            warehouse.Address1      = CommonHelper.EnsureNotNull(warehouse.Address1);
            warehouse.Address1      = CommonHelper.EnsureMaximumLength(warehouse.Address1, 100);
            warehouse.Address2      = CommonHelper.EnsureNotNull(warehouse.Address2);
            warehouse.Address2      = CommonHelper.EnsureMaximumLength(warehouse.Address2, 100);
            warehouse.City          = CommonHelper.EnsureNotNull(warehouse.City);
            warehouse.City          = CommonHelper.EnsureMaximumLength(warehouse.City, 100);
            warehouse.StateProvince = CommonHelper.EnsureNotNull(warehouse.StateProvince);
            warehouse.StateProvince = CommonHelper.EnsureMaximumLength(warehouse.StateProvince, 100);
            warehouse.ZipPostalCode = CommonHelper.EnsureNotNull(warehouse.ZipPostalCode);
            warehouse.ZipPostalCode = CommonHelper.EnsureMaximumLength(warehouse.ZipPostalCode, 30);



            _context.Warehouses.AddObject(warehouse);
            _context.SaveChanges();
        }
コード例 #3
0
        /// <summary>
        /// Inserts category
        /// </summary>
        /// <param name="category">Category</param>
        public void InsertCategory(Category category)
        {
            if (category == null)
            {
                throw new ArgumentNullException("category");
            }

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



            _context.Categories.AddObject(category);
            _context.SaveChanges();

            if (this.CategoriesCacheEnabled || this.MappingsCacheEnabled)
            {
                _cacheManager.RemoveByPattern(CATEGORIES_PATTERN_KEY);
                _cacheManager.RemoveByPattern(PRODUCTCATEGORIES_PATTERN_KEY);
            }
        }
コード例 #4
0
        /// <summary>
        /// Inserts a manufacturer
        /// </summary>
        /// <param name="manufacturer">Manufacturer</param>
        public void InsertManufacturer(Manufacturer manufacturer)
        {
            if (manufacturer == null)
            {
                throw new ArgumentNullException("manufacturer");
            }

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



            _context.Manufacturers.AddObject(manufacturer);
            _context.SaveChanges();

            if (this.ManufacturersCacheEnabled || this.MappingsCacheEnabled)
            {
                _cacheManager.RemoveByPattern(MANUFACTURERS_PATTERN_KEY);
                _cacheManager.RemoveByPattern(PRODUCTMANUFACTURERS_PATTERN_KEY);
            }
        }
コード例 #5
0
        /// <summary>
        /// Inserts a search log item
        /// </summary>
        /// <param name="searchLog">Search log item</param>
        public void InsertSearchLog(SearchLog searchLog)
        {
            if (searchLog == null)
            {
                throw new ArgumentNullException("searchLog");
            }

            searchLog.SearchTerm = CommonHelper.EnsureNotNull(searchLog.SearchTerm);
            searchLog.SearchTerm = CommonHelper.EnsureMaximumLength(searchLog.SearchTerm, 100);



            _context.SearchLog.AddObject(searchLog);
            _context.SaveChanges();
        }
コード例 #6
0
        /// <summary>
        /// Creates a new QBEntity
        /// </summary>
        /// <param name="entity">QBEntity</param>
        public void CreateQBEntity(QBEntity entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }

            entity.QBEntityId = CommonHelper.EnsureNotNull(entity.QBEntityId);
            entity.QBEntityId = CommonHelper.EnsureMaximumLength(entity.QBEntityId, 50);
            entity.SeqNum     = CommonHelper.EnsureNotNull(entity.SeqNum);
            entity.SeqNum     = CommonHelper.EnsureMaximumLength(entity.SeqNum, 20);

            _context.QBEntities.AddObject(entity);
            _context.SaveChanges();
        }
コード例 #7
0
ファイル: QBManager.cs プロジェクト: terry2012/DSV
        /// <summary>
        /// Updates QBEntity
        /// </summary>
        /// <param name="entityId">Entity ID</param>
        /// <param name="qbEntityId">QuickBooks entity ID</param>
        /// <param name="entityType">Entity type</param>
        /// <param name="nopEntityId">nopCommerce entity ID</param>
        /// <param name="synState">Synchronization state</param>
        /// <param name="seqNum">Edit sequence number</param>
        /// <returns>QBEntity</returns>
        public static QBEntity UpdateQBEntity(int entityId, string qbEntityId, EntityTypeEnum entityType, int nopEntityId, SynStateEnum synState, string seqNum)
        {
            QBEntity entity = GetQBEntityById(entityId);

            if (entity == null)
            {
                return(null);
            }

            NopObjectContext context = ObjectContextHelper.CurrentObjectContext;

            if (!context.IsAttached(entity))
            {
                context.QBEntities.Attach(entity);
            }

            entity.QBEntityId  = CommonHelper.EnsureMaximumLength(qbEntityId, 50);
            entity.EntityType  = entityType;
            entity.NopEntityId = nopEntityId;
            entity.SynState    = synState;
            entity.SeqNum      = CommonHelper.EnsureMaximumLength(seqNum, 20);
            entity.CreatedOn   = entity.CreatedOn;
            entity.UpdatedOn   = DateTime.UtcNow;

            context.SaveChanges();

            return(entity);
        }
コード例 #8
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();
        }
コード例 #9
0
        /// <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();
        }
コード例 #10
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();
        }
コード例 #11
0
        /// <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();
        }
コード例 #12
0
        /// <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();
        }
コード例 #13
0
        /// <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();
        }
コード例 #14
0
        /// <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);
            }
        }
コード例 #15
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);
            }
        }
コード例 #16
0
        /// <summary>
        /// Deletes a state/province
        /// </summary>
        /// <param name="stateProvinceId">The state/province identifier</param>
        public void DeleteStateProvince(int stateProvinceId)
        {
            var stateProvince = GetStateProvinceById(stateProvinceId);

            if (stateProvince == null)
            {
                return;
            }


            if (!_context.IsAttached(stateProvince))
            {
                _context.StateProvinces.Attach(stateProvince);
            }
            _context.DeleteObject(stateProvince);
            _context.SaveChanges();

            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(STATEPROVINCES_PATTERN_KEY);
            }
        }
コード例 #17
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);
            }
        }
コード例 #18
0
        /// <summary>
        /// Deletes a tax rate
        /// </summary>
        /// <param name="taxRateId">Tax rate identifier</param>
        public void DeleteTaxRate(int taxRateId)
        {
            var taxRate = GetTaxRateById(taxRateId);

            if (taxRate == null)
            {
                return;
            }


            if (!_context.IsAttached(taxRate))
            {
                _context.TaxRates.Attach(taxRate);
            }
            _context.DeleteObject(taxRate);
            _context.SaveChanges();

            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(TAXRATE_PATTERN_KEY);
            }
        }
コード例 #19
0
        /// <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);
            }
        }
コード例 #20
0
        /// <summary>
        /// Deletes a SMS provider
        /// </summary>
        /// <param name="smsProviderId">SMS provider identifier</param>
        public void DeleteSMSProvider(int smsProviderId)
        {
            var smsProvider = GetSMSProviderById(smsProviderId);

            if (smsProvider == null)
            {
                return;
            }


            if (!_context.IsAttached(smsProvider))
            {
                _context.SMSProviders.Attach(smsProvider);
            }
            _context.DeleteObject(smsProvider);
            _context.SaveChanges();

            if (CacheEnabled)
            {
                _cacheManager.RemoveByPattern(SMSPROVIDERS_PATTERN_KEY);
            }
        }
コード例 #21
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);
            }
        }
コード例 #22
0
        /// <summary>
        /// Deletes a language
        /// </summary>
        /// <param name="languageId">Language identifier</param>
        public void DeleteLanguage(int languageId)
        {
            var language = GetLanguageById(languageId);

            if (language == null)
            {
                return;
            }


            if (!_context.IsAttached(language))
            {
                _context.Languages.Attach(language);
            }
            _context.DeleteObject(language);
            _context.SaveChanges();

            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(LANGUAGES_PATTERN_KEY);
            }
        }
コード例 #23
0
        /// <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);
            }
        }
コード例 #24
0
        /// <summary>
        /// Inserts an affiliate
        /// </summary>
        /// <param name="affiliate">Affiliate</param>
        public void InsertAffiliate(Affiliate affiliate)
        {
            if (affiliate == null)
            {
                throw new ArgumentNullException("affiliate");
            }

            affiliate.FirstName     = CommonHelper.EnsureNotNull(affiliate.FirstName);
            affiliate.LastName      = CommonHelper.EnsureNotNull(affiliate.LastName);
            affiliate.FirstName     = CommonHelper.EnsureMaximumLength(affiliate.FirstName, 100);
            affiliate.LastName      = CommonHelper.EnsureMaximumLength(affiliate.LastName, 100);
            affiliate.MiddleName    = CommonHelper.EnsureNotNull(affiliate.MiddleName);
            affiliate.MiddleName    = CommonHelper.EnsureMaximumLength(affiliate.MiddleName, 100);
            affiliate.PhoneNumber   = CommonHelper.EnsureNotNull(affiliate.PhoneNumber);
            affiliate.PhoneNumber   = CommonHelper.EnsureMaximumLength(affiliate.PhoneNumber, 50);
            affiliate.Email         = CommonHelper.EnsureNotNull(affiliate.Email);
            affiliate.Email         = CommonHelper.EnsureMaximumLength(affiliate.Email, 255);
            affiliate.FaxNumber     = CommonHelper.EnsureNotNull(affiliate.FaxNumber);
            affiliate.FaxNumber     = CommonHelper.EnsureMaximumLength(affiliate.FaxNumber, 50);
            affiliate.Company       = CommonHelper.EnsureNotNull(affiliate.Company);
            affiliate.Company       = CommonHelper.EnsureMaximumLength(affiliate.Company, 100);
            affiliate.Address1      = CommonHelper.EnsureNotNull(affiliate.Address1);
            affiliate.Address1      = CommonHelper.EnsureMaximumLength(affiliate.Address1, 100);
            affiliate.Address2      = CommonHelper.EnsureNotNull(affiliate.Address2);
            affiliate.Address2      = CommonHelper.EnsureMaximumLength(affiliate.Address2, 100);
            affiliate.City          = CommonHelper.EnsureNotNull(affiliate.City);
            affiliate.City          = CommonHelper.EnsureMaximumLength(affiliate.City, 100);
            affiliate.StateProvince = CommonHelper.EnsureNotNull(affiliate.StateProvince);
            affiliate.StateProvince = CommonHelper.EnsureMaximumLength(affiliate.StateProvince, 100);
            affiliate.ZipPostalCode = CommonHelper.EnsureNotNull(affiliate.ZipPostalCode);
            affiliate.ZipPostalCode = CommonHelper.EnsureMaximumLength(affiliate.ZipPostalCode, 30);



            _context.Affiliates.AddObject(affiliate);
            _context.SaveChanges();
        }
コード例 #25
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);
            }
        }
コード例 #26
0
        /// <summary>
        /// Persistance test helper
        /// </summary>
        /// <typeparam name="T">Entity type</typeparam>
        /// <param name="entity">Entity</param>
        /// <param name="disposeContext">A value indicating whether to dispose context</param>
        protected T SaveAndLoadEntity <T>(T entity, bool disposeContext = true) where T : BaseEntity
        {
            context.Set <T>().Add(entity);
            context.SaveChanges();

            object id = entity.Id;

            if (disposeContext)
            {
                context.Dispose();
                context = new NopObjectContext(GetTestDbName());
            }

            var fromDb = context.Set <T>().Find(id);

            return(fromDb);
        }
コード例 #27
0
ファイル: QBManager.cs プロジェクト: terry2012/DSV
        /// <summary>
        /// Creates a new QBEntity
        /// </summary>
        /// <param name="qbEntityId">QBEntity ID</param>
        /// <param name="entityType">Entity type</param>
        /// <param name="nopEntityId">nopCommerce entity ID</param>
        /// <param name="synState">Synchronization state</param>
        /// <param name="seqNum">Edit sequence number</param>
        /// <returns>QBEntity</returns>
        public static QBEntity CreateQBEntity(string qbEntityId, EntityTypeEnum entityType, int nopEntityId, SynStateEnum synState, string seqNum)
        {
            NopObjectContext context = ObjectContextHelper.CurrentObjectContext;
            QBEntity         entity  = context.QBEntities.CreateObject();

            entity.QBEntityId  = CommonHelper.EnsureMaximumLength(qbEntityId, 50);
            entity.EntityType  = entityType;
            entity.NopEntityId = nopEntityId;
            entity.SynState    = synState;
            entity.SeqNum      = CommonHelper.EnsureMaximumLength(seqNum, 20);
            entity.CreatedOn   = DateTime.UtcNow;
            entity.UpdatedOn   = DateTime.UtcNow;

            context.QBEntities.AddObject(entity);
            context.SaveChanges();

            return(entity);
        }
コード例 #28
0
        /// <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);
            }
        }
コード例 #29
0
        /// <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);
            }
        }
コード例 #30
0
ファイル: Products.cs プロジェクト: jasonholloway/brigita
        public static void Build()
        {
            var ctx = new NopObjectContext("Data Source=JASON-THINK;Initial Catalog=Brigita;Integrated Security=True;Persist Security Info=False");
            var products = ctx.Set<Product>();

            var cats = ctx.Set<Category>().ToArray();
            var pic = ctx.Set<Picture>().OrderByDescending(p => p.ID).First();

            foreach(var cat in cats) {
                for(int i = 0; i < 100; i++) {

                    var p = new Product() {
                        Name = "Product" + i,
                        CreatedOnUtc = DateTime.UtcNow,
                        UpdatedOnUtc = DateTime.UtcNow,
                        ShortDescription = "Short desc blah blah blah blah blah.",
                        FullDescription = "Full desc blah blah blah blah blah blah blah blah blah blah blah blah blah..."
                        //...
                    };

                    p.ProductCategories.Add(new ProductCategory() {
                                                        Category = cat
                                                    });

                    p.ProductPictures.Add(new ProductPicture() {
                                                        Picture = pic
                                                    });

                    products.Add(p);
                }
            }

            try {
                ctx.SaveChanges();
            }
            catch(Exception ex) {
                //...
            }
        }
コード例 #31
0
        /// <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();
        }