当前位置: 首页>>代码示例>>C#>>正文


C# Catalog.Category类代码示例

本文整理汇总了C#中Nop.Core.Domain.Catalog.Category的典型用法代码示例。如果您正苦于以下问题:C# Category类的具体用法?C# Category怎么用?C# Category使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Category类属于Nop.Core.Domain.Catalog命名空间,在下文中一共展示了Category类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Entities_with_same_id_but_different_type_should_not_be_equal

        public void Entities_with_same_id_but_different_type_should_not_be_equal() {
            int id = 10;
            var p1 = new Product { Id = id };

            var c1 = new Category { Id = id };

            Assert.AreNotEqual(p1, c1, "Entities of different types should not be equal, even if they have the same id");
        }
开发者ID:haithemChkel,项目名称:nopCommerce_33,代码行数:8,代码来源:EntityEqualityTests.cs

示例2: DeleteCategory

        /// <summary>
        /// Delete category
        /// </summary>
        /// <param name="category">Category</param>
        public virtual void DeleteCategory(Category category)
        {
            if (category == null)
                throw new ArgumentNullException("category");

            category.Deleted = true;
            UpdateCategory(category);
        }
开发者ID:pquic,项目名称:qCommerce,代码行数:12,代码来源:CategoryService.cs

示例3: Can_save_and_load_category

        public void Can_save_and_load_category()
        {
            var category = new Category
                               {
                                   Name = "Books",
                                   Description = "Description 1",
                                   CategoryTemplateId = 1,
                                   MetaKeywords = "Meta keywords",
                                   MetaDescription = "Meta description",
                                   MetaTitle = "Meta title",
                                   ParentCategoryId = 2,
                                   PictureId = 3,
                                   PageSize = 4,
                                   AllowCustomersToSelectPageSize = true,
                                   PageSizeOptions = "4, 2, 8, 12",
                                   PriceRanges = "1-3;",
                                   ShowOnHomePage = false,
                                   IncludeInTopMenu = true,
                                   HasDiscountsApplied = true,
                                   Published = true,
                                   SubjectToAcl = true,
                                   LimitedToStores = true,
                                   Deleted = false,
                                   DisplayOrder = 5,
                                   CreatedOnUtc = new DateTime(2010, 01, 01),
                                   UpdatedOnUtc = new DateTime(2010, 01, 02),
                               };

            var fromDb = SaveAndLoadEntity(category);
            fromDb.ShouldNotBeNull();
            fromDb.Name.ShouldEqual("Books");
            fromDb.Description.ShouldEqual("Description 1");
            fromDb.CategoryTemplateId.ShouldEqual(1);
            fromDb.MetaKeywords.ShouldEqual("Meta keywords");
            fromDb.MetaDescription.ShouldEqual("Meta description");
            fromDb.ParentCategoryId.ShouldEqual(2);
            fromDb.PictureId.ShouldEqual(3);
            fromDb.PageSize.ShouldEqual(4);
            fromDb.AllowCustomersToSelectPageSize.ShouldEqual(true);
            fromDb.PageSizeOptions.ShouldEqual("4, 2, 8, 12");
            fromDb.PriceRanges.ShouldEqual("1-3;");
            fromDb.ShowOnHomePage.ShouldEqual(false);
            fromDb.IncludeInTopMenu.ShouldEqual(true);
            fromDb.HasDiscountsApplied.ShouldEqual(true);
            fromDb.Published.ShouldEqual(true);
            fromDb.SubjectToAcl.ShouldEqual(true);
            fromDb.LimitedToStores.ShouldEqual(true);
            fromDb.Deleted.ShouldEqual(false);
            fromDb.DisplayOrder.ShouldEqual(5);
            fromDb.CreatedOnUtc.ShouldEqual(new DateTime(2010, 01, 01));
            fromDb.UpdatedOnUtc.ShouldEqual(new DateTime(2010, 01, 02));
        }
开发者ID:rajendra1809,项目名称:nopCommerce,代码行数:52,代码来源:CategoryPersistenceTests.cs

示例4: DeleteCategory

        /// <summary>
        /// Delete category
        /// </summary>
        /// <param name="category">Category</param>
        public virtual void DeleteCategory(Category category)
        {
            if (category == null)
                throw new ArgumentNullException("category");

            category.Deleted = true;
            UpdateCategory(category);

            //set a ParentCategory property of the children to 0
            var subcategories = GetAllCategoriesByParentCategoryId(category.Id);
            foreach (var subcategory in subcategories)
            {
                subcategory.ParentCategoryId = 0;
                UpdateCategory(subcategory);
            }
        }
开发者ID:kramerica-industries,项目名称:eCommerce,代码行数:20,代码来源:CategoryService.cs

示例5: Can_save_and_load_category_with_productCategories

        public void Can_save_and_load_category_with_productCategories()
        {
            var category = new Category
                               {
                                   Name = "Books",
                                   Description = "Description 1",
                                   MetaKeywords = "Meta keywords",
                                   MetaDescription = "Meta description",
                                   MetaTitle = "Meta title",
                                   SeName = "SE name",
                                   ParentCategoryId = 2,
                                   PictureId = 3,
                                   PageSize = 4,
                                   AllowCustomersToSelectPageSize = true,
                                   PageSizeOptions = "4, 2, 8, 12",
                                   PriceRanges = "1-3;",
                                   ShowOnHomePage = false,
                                   Published = true,
                                   Deleted = false,
                                   DisplayOrder = 5,
                                   CreatedOnUtc = new DateTime(2010, 01, 01),
                                   UpdatedOnUtc = new DateTime(2010, 01, 02)
                               };
            category.ProductCategories.Add
                (
                    new ProductCategory
                    {
                        IsFeaturedProduct = true,
                        DisplayOrder = 1,
                        Product = new Product()
                        {
                            Name = "Name 1",
                            Published = true,
                            Deleted = false,
                            CreatedOnUtc = new DateTime(2010, 01, 01),
                            UpdatedOnUtc = new DateTime(2010, 01, 02)
                        }
                    }
                );
            var fromDb = SaveAndLoadEntity(category);
            fromDb.ShouldNotBeNull();
            fromDb.Name.ShouldEqual("Books");

            fromDb.ProductCategories.ShouldNotBeNull();
            (fromDb.ProductCategories.Count == 1).ShouldBeTrue();
            fromDb.ProductCategories.First().IsFeaturedProduct.ShouldEqual(true);
        }
开发者ID:cmcginn,项目名称:StoreFront,代码行数:47,代码来源:CategoryPersistenceTests.cs

示例6: GetCategoryBreadCrumb

        private IList<Category> GetCategoryBreadCrumb(Category category)
        {
            if (category == null)
                throw new ArgumentNullException("category");

            var breadCrumb = new List<Category>();

            while (category != null && //category is not null
                !category.Deleted && //category is not deleted
                category.Published) //category is published
            {
                breadCrumb.Add(category);
                category = _categoryService.GetCategoryById(category.ParentCategoryId);
            }
            breadCrumb.Reverse();
            return breadCrumb;
        }
开发者ID:philipengland,项目名称:albionextrusions.co.uk,代码行数:17,代码来源:BecomeService.cs

示例7: SaveCategoryAcl

 protected void SaveCategoryAcl(Category category, CategoryModel model)
 {
     var existingAclRecords = _aclService.GetAclRecords(category);
     var allCustomerRoles = _customerService.GetAllCustomerRoles(true);
     foreach (var customerRole in allCustomerRoles)
     {
         if (model.SelectedCustomerRoleIds != null && model.SelectedCustomerRoleIds.Contains(customerRole.Id))
         {
             //new role
             if (existingAclRecords.Count(acl => acl.CustomerRoleId == customerRole.Id) == 0)
                 _aclService.InsertAclRecord(category, customerRole.Id);
         }
         else
         {
             //removed role
             var aclRecordToDelete = existingAclRecords.FirstOrDefault(acl => acl.CustomerRoleId == customerRole.Id);
             if (aclRecordToDelete != null)
                 _aclService.DeleteAclRecord(aclRecordToDelete);
         }
     }
 }
开发者ID:nkasar,项目名称:nopCommerce,代码行数:21,代码来源:CategoryController.cs

示例8: PrepareAclModel

        private void PrepareAclModel(CategoryModel model, Category category, bool excludeProperties)
        {
            if (model == null)
                throw new ArgumentNullException("model");

            model.AvailableCustomerRoles = _customerService
                .GetAllCustomerRoles(true)
                .Select(cr => cr.ToModel())
                .ToList();
            if (!excludeProperties)
            {
                if (category != null)
                {
                    model.SelectedCustomerRoleIds = _aclService.GetCustomerRoleIdsWithAccess(category);
                }
                else
                {
                    model.SelectedCustomerRoleIds = new int[0];
                }
            }
        }
开发者ID:nkasar,项目名称:nopCommerce,代码行数:21,代码来源:CategoryController.cs

示例9: LoadSpecsFilters

            public virtual void LoadSpecsFilters(Category category, 
                ISpecificationAttributeService specificationAttributeService, IWebHelper webHelper, 
                IWorkContext workContext)
            {
                if (category == null)
                    throw new ArgumentNullException("category");

                var alreadyFilteredOptions = GetAlreadyFilteredSpecs(specificationAttributeService, webHelper, workContext);
                var notFilteredOptions = GetNotFilteredSpecs(category.Id,
                    specificationAttributeService, webHelper, workContext);

                if (alreadyFilteredOptions.Count > 0 || notFilteredOptions.Count > 0)
                {
                    this.Enabled = true;

                    this.AlreadyFilteredItems = alreadyFilteredOptions.ToList().Select(x =>
                    {
                        var item = new SpecificationFilterItem();
                        item.SpecificationAttributeName = x.SpecificationAttributeName;
                        item.SpecificationAttributeOptionName = x.SpecificationAttributeOptionName;

                        return item;
                    }).ToList();

                    this.NotFilteredItems = notFilteredOptions.ToList().Select(x =>
                    {
                        var item = new SpecificationFilterItem();
                        item.SpecificationAttributeName = x.SpecificationAttributeName;
                        item.SpecificationAttributeOptionName = x.SpecificationAttributeOptionName;

                        //filter URL
                        var alreadyFilteredOptionIds = GetAlreadyFilteredSpecOptionIds(webHelper);
                        if (!alreadyFilteredOptionIds.Contains(x.SpecificationAttributeOptionId))
                            alreadyFilteredOptionIds.Add(x.SpecificationAttributeOptionId);
                        string newQueryParam = GenerateFilteredSpecQueryParam(alreadyFilteredOptionIds);
                        string filterUrl = webHelper.ModifyQueryString(webHelper.GetThisPageUrl(true), QUERYSTRINGPARAM + "=" + newQueryParam, null);
                        filterUrl = ExcludeQueryStringParams(filterUrl, webHelper);
                        item.FilterUrl = filterUrl;

                        return item;
                    }).ToList();

                    //remove filter URL
                    string removeFilterUrl = webHelper.RemoveQueryString(webHelper.GetThisPageUrl(true), QUERYSTRINGPARAM);
                    removeFilterUrl = ExcludeQueryStringParams(removeFilterUrl, webHelper);
                    this.RemoveFilterUrl = removeFilterUrl;
                }
                else
                {
                    this.Enabled = false;
                }
            }
开发者ID:pquic,项目名称:qCommerce,代码行数:52,代码来源:CatalogPagingFilteringModel.cs

示例10: UpdateCategory

        /// <summary>
        /// Updates the category
        /// </summary>
        /// <param name="category">Category</param>
        public virtual void UpdateCategory(Category category)
        {
            if (category == null)
                throw new ArgumentNullException("category");

            //validate category hierarchy
            var parentCategory = GetCategoryById(category.ParentCategoryId);
            while (parentCategory != null)
            {
                if (category.Id == parentCategory.Id)
                {
                    category.ParentCategoryId = 0;
                    break;
                }
                parentCategory = GetCategoryById(parentCategory.ParentCategoryId);
            }

            _categoryRepository.Update(category);

            //cache
            _cacheManager.RemoveByPattern(CATEGORIES_PATTERN_KEY);
            _cacheManager.RemoveByPattern(PRODUCTCATEGORIES_PATTERN_KEY);

            //event notification
            _eventPublisher.EntityUpdated(category);
        }
开发者ID:pquic,项目名称:qCommerce,代码行数:30,代码来源:CategoryService.cs

示例11: PrepareAclModel

        protected virtual void PrepareAclModel(CategoryModel model, Category category, bool excludeProperties)
        {
            if (model == null)
                throw new ArgumentNullException("model");

            if (!excludeProperties && category != null)
                model.SelectedCustomerRoleIds = _aclService.GetCustomerRoleIdsWithAccess(category).ToList();

            var allRoles = _customerService.GetAllCustomerRoles(true);
            foreach (var role in allRoles)
            {
                model.AvailableCustomerRoles.Add(new SelectListItem
                {
                    Text = role.Name,
                    Value = role.Id.ToString(),
                    Selected = model.SelectedCustomerRoleIds.Contains(role.Id)
                });
            }
        }
开发者ID:RobinHoody,项目名称:nopCommerce,代码行数:19,代码来源:CategoryController.cs

示例12: UpdateLocales

        protected void UpdateLocales(Category category, CategoryModel model)
        {
            foreach (var localized in model.Locales)
            {
                _localizedEntityService.SaveLocalizedValue(category,
                                                               x => x.Name,
                                                               localized.Name,
                                                               localized.LanguageId);

                _localizedEntityService.SaveLocalizedValue(category,
                                                           x => x.Description,
                                                           localized.Description,
                                                           localized.LanguageId);

                _localizedEntityService.SaveLocalizedValue(category,
                                                           x => x.MetaKeywords,
                                                           localized.MetaKeywords,
                                                           localized.LanguageId);

                _localizedEntityService.SaveLocalizedValue(category,
                                                           x => x.MetaDescription,
                                                           localized.MetaDescription,
                                                           localized.LanguageId);

                _localizedEntityService.SaveLocalizedValue(category,
                                                           x => x.MetaTitle,
                                                           localized.MetaTitle,
                                                           localized.LanguageId);

                //search engine name
                var seName = category.ValidateSeName(localized.SeName, localized.Name, false);
                _urlRecordService.SaveSlug(category, seName, localized.LanguageId);
            }
        }
开发者ID:nkasar,项目名称:nopCommerce,代码行数:34,代码来源:CategoryController.cs

示例13: PrepareAclModel

        protected virtual void PrepareAclModel(CategoryModel model, Category category, bool excludeProperties)
        {
            if (model == null)
                throw new ArgumentNullException("model");

            model.AvailableCustomerRoles = _customerService
                .GetAllCustomerRoles(true)
                .Select(cr => cr.ToModel())
                .ToList();
            if (!excludeProperties)
            {
                if (category != null)
                {
                    model.SelectedCustomerRoleIds = category.CustomerRoles.ToArray();
                }
            }
        }
开发者ID:freemsly,项目名称:grandnode,代码行数:17,代码来源:CategoryController.cs

示例14: ResolveCategory

        private Category ResolveCategory(string categoryName, Category parentCategory)
        {
            Category currentCategory = _categoryService.GetAllCategories(categoryName).FirstOrDefault();
            if (currentCategory != null) return currentCategory;
            currentCategory = new Category
            {
                Name = categoryName,
                MetaTitle = categoryName,
                MetaDescription = categoryName,
                MetaKeywords = categoryName,
                AllowCustomersToSelectPageSize = true,
                HasDiscountsApplied = false,
                CategoryTemplateId = 1,
                //Description = categoryName,
                DisplayOrder = 1,
                IncludeInTopMenu = false,
                PageSize = 8,
                PageSizeOptions = "12,8,4",
                ParentCategoryId = parentCategory != null ? parentCategory.Id : 0,
                ShowOnHomePage = false,
                SubjectToAcl = false,
                LimitedToStores = false,
                Published = true,
                CreatedOnUtc = DateTime.UtcNow,
                UpdatedOnUtc = DateTime.UtcNow
            };
            _categoryService.InsertCategory(currentCategory);
            _urlRecordService.SaveSlug(currentCategory, currentCategory.ValidateSeName(categoryName, categoryName, true),
                0);

            return _categoryService.GetAllCategories(categoryName).First();
        }
开发者ID:aleks279,项目名称:atrend-test,代码行数:32,代码来源:ProductResolver.cs

示例15: GetC5ProductCategories

 private ICollection<Category> GetC5ProductCategories(C5Product c5Product)
 {
     var categories = new List<Category>();
     foreach (var categoryName in c5Product.CategoryName.Split(','))
     {
         var existingCategories = _categoryService.GetAllCategories(categoryName, true);
         if (existingCategories.Count > 1)
         {
             foreach (var category in existingCategories)
             {
                 _categoryService.DeleteCategory(category);
             }
         }
         if (existingCategories.Count > 0)
         {
             categories.Add(existingCategories.First());
         }
         else {
             var category = new Category()
             {
                 CreatedOnUtc = DateTime.UtcNow,
                 UpdatedOnUtc = DateTime.UtcNow,
                 Name = c5Product.CategoryName,
                 Published = true
             };
             _categoryService.InsertCategory(category);
             categories.Add(category);
         }
     }
     return categories;
 }
开发者ID:Schtolz,项目名称:NopcommerceC5,代码行数:31,代码来源:ProductsImportService.cs


注:本文中的Nop.Core.Domain.Catalog.Category类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。