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


C# IProduct.AddToCollection方法代码示例

本文整理汇总了C#中IProduct.AddToCollection方法的典型用法代码示例。如果您正苦于以下问题:C# IProduct.AddToCollection方法的具体用法?C# IProduct.AddToCollection怎么用?C# IProduct.AddToCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IProduct的用法示例。


在下文中一共展示了IProduct.AddToCollection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FixtureSetup

        public override void FixtureSetup()
        {
            base.FixtureSetup();

            #region clean up
            _detachedContentTypeService = ((ServiceContext)MerchelloContext.Current.Services).DetachedContentTypeService;

            var existingContentTypes = _detachedContentTypeService.GetAll();
            foreach (var t in existingContentTypes)
            {
                ((ServiceContext)MerchelloContext.Current.Services).DetachedContentTypeService.Delete(t);
            }

            DbPreTestDataWorker.DeleteAllProducts();
            DbPreTestDataWorker.DeleteAllEntityCollections();
            #endregion

            var catalog = DbPreTestDataWorker.WarehouseCatalog;

            var detachedContentType =
                ((ServiceContext)MerchelloContext.Current.Services).DetachedContentTypeService
                    .CreateDetachedContentTypeWithKey(EntityType.Product, new Guid(), "TEST");

            _productService = DbPreTestDataWorker.ProductService;
            _entityCollectionService = DbPreTestDataWorker.EntityCollectionService;

            var collection1 =
                _entityCollectionService.CreateEntityCollection(
                EntityType.Product,
                Core.Constants.ProviderKeys.EntityCollection.StaticProductCollectionProviderKey,
                "Collection1");

            var collection2 =
                _entityCollectionService.CreateEntityCollection(
                EntityType.Product,
                Core.Constants.ProviderKeys.EntityCollection.StaticProductCollectionProviderKey,
                "Collection2");

            this._original = DbPreTestDataWorker.MakeExistingProduct();
            _original.Barcode = "barcode";
            _original.Manufacturer = "manufacturer";
            _original.ManufacturerModelNumber = "modelnumber";
            _original.CostOfGoods = 1M;
            _original.OnSale = false;
            _original.SalePrice = 2M;
            _original.Taxable = true;
            _original.Shippable = true;
            _original.Height = 2;
            _original.Weight = 2;
            _original.Width = 2;
            _original.Length = 2;
            _original.Available = true;
            _original.Download = false;
            _original.OutOfStockPurchase = true;
            _original.AddToCatalogInventory(catalog);
            this._original.ProductOptions.Add(new ProductOption("Color"));
            this._original.ProductOptions.First(x => x.Name == "Color").Choices.Add(new ProductAttribute("Black", "Blk"));
            this._original.ProductOptions.First(x => x.Name == "Color").Choices.Add(new ProductAttribute("Blue", "Blu"));
            this._original.ProductOptions.First(x => x.Name == "Color").Choices.Add(new ProductAttribute("Red", "Red"));
            this._original.ProductOptions.First(x => x.Name == "Color").Choices.Add(new ProductAttribute("Green", "Gre"));
            this._original.ProductOptions.Add(new ProductOption("Size"));
            this._original.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("Small", "Sm"));
            this._original.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("Medium", "M"));
            this._original.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("Large", "Lg"));
            this._original.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("X-Large", "XL"));
            this._original.Height = 20;
            this._original.Weight = 20;
            this._original.Length = 20;
            this._original.Width = 20;
            this._original.Shippable = true;
            _productService.Save(this._original);

            _original.AddToCollection(collection1);
            _original.AddToCollection(collection2);

            this._original.DetachedContents.Add(
                new ProductVariantDetachedContent(
                    this._original.ProductVariantKey,
                    detachedContentType,
                    "en-US",
                    new DetachedDataValuesCollection(
                        new[]
                            {
                                new KeyValuePair<string, string>(
                                    "description",
                                    "\"<p><span>Made with real avocados, this Avocado Moisturizing Bar is great for dry skin. Layers of color are achieved by using oxide colorants. Scented with Wasabi Fragrance Oil, this soap smells slightly spicy, making it a great choice for both men and women. To ensure this soap does not overheat, place in the freezer to keep cool and prevent gel phase.</span></p>\""),
                                new KeyValuePair<string, string>(
                                    "brief",
                                    "\"Avocado Moisturizing Bar is great for dry skin.\""),
                                new KeyValuePair<string, string>(
                                    "image",
                                    "{ \"focalPoint\": { \"left\": 0.5, \"top\": 0.5 }, \"src\": \"/media/1035/avocadobars.jpg\" }"),
                            }))
                {
                    CanBeRendered = true
                });

            this._original.DetachedContents.Add(
                new ProductVariantDetachedContent(
                    this._original.ProductVariantKey,
//.........这里部分代码省略.........
开发者ID:Nikita-reddy,项目名称:Merchello,代码行数:101,代码来源:CopyProductTests.cs


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