當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。