コード例 #1
0
        private DataTypeEnum GenerateColourDataTypeEnum(string colour, DataType parentDataType)
        {
            var dataTypeEnum = DataTypeEnum.SingleOrDefault(x => x.Value == colour && x.DataType.DataTypeId == parentDataType.DataTypeId) ?? new DataTypeEnumFactory().NewWithDefaults(colour);

            dataTypeEnum.Deleted  = false;
            dataTypeEnum.DataType = DataType.Get(parentDataType.DataTypeId);
            dataTypeEnum.Save();

            GenericHelpers.DoForEachCulture(language =>
            {
                if (dataTypeEnum.GetDescription(language) == null)
                {
                    dataTypeEnum.AddDescription(new DataTypeEnumDescription {
                        CultureCode = language, DisplayName = colour, Description = colour
                    });
                }
            });

            return(dataTypeEnum);
        }
コード例 #2
0
        private static Category CreateCategory(ProductCatalog catalog, string name, string imageId)
        {
            var definition = GetDefaultDefinition();
            var category   = Category.SingleOrDefault(c => c.Name == name) ?? new CategoryFactory().NewWithDefaults(catalog, definition, name);

            category.DisplayOnSite = true;

            GenericHelpers.DoForEachCulture(language =>
            {
                if (category.GetDescription(language) == null)
                {
                    category.AddCategoryDescription(new CategoryDescription()
                    {
                        CultureCode = language, DisplayName = name
                    });
                }
            });

            category.ImageMediaId = imageId;
            category.Save();
            return(category);
        }
コード例 #3
0
        private static Category CreateCategory(ProductCatalog catalog, string name)
        {
            var definition      = Definition.SingleOrDefault(d => d.Name == "Default Category Definition");
            var categoryFactory = ObjectFactory.Instance.Resolve <ICategoryFactory>();
            var category        = Category.SingleOrDefault(c => c.Name == name) ??
                                  categoryFactory.NewWithDefaults(catalog, definition, name);

            category.DisplayOnSite = true;

            GenericHelpers.DoForEachCulture(language =>
            {
                if (category.GetDescription(language) == null)
                {
                    category.AddCategoryDescription(new CategoryDescription()
                    {
                        CultureCode = language, DisplayName = name
                    });
                }
            });

            category.Save();
            return(category);
        }