コード例 #1
0
 /// <summary>
 /// The detached content type service on deleting.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="e">
 /// The e.
 /// </param>
 private void DetachedContentTypeServiceOnDeleting(IDetachedContentTypeService sender, DeleteEventArgs <IDetachedContentType> e)
 {
     foreach (var dc in e.DeletedEntities)
     {
         // remove detached content from products
         var products = MerchelloContext.Current.Services.ProductService.GetByDetachedContentType(dc.Key);
         MerchelloContext.Current.Services.ProductService.RemoveDetachedContent(products, dc.Key);
     }
 }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DetachedContentApiController"/> class.
        /// </summary>
        /// <param name="merchelloContext">
        /// The <see cref="IMerchelloContext"/>.
        /// </param>
        /// <param name="umbracoContext">
        /// The <see cref="UmbracoContext"/>.
        /// </param>
        public DetachedContentApiController(IMerchelloContext merchelloContext, UmbracoContext umbracoContext)
            : base(merchelloContext, umbracoContext)
        {
            if (ApplicationContext == null)
            {
                throw new NotFiniteNumberException("Umbraco ApplicationContext is null");
            }

            _contentTypeService = ApplicationContext.Services.ContentTypeService;

            _detachedContentTypeService = ((ServiceContext)merchelloContext.Services).DetachedContentTypeService;
        }
コード例 #3
0
        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,
                    detachedContentType,
                    "en-GB",
                    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
                });

            var firstVariant = _original.ProductVariants.First();

            firstVariant.DetachedContents.Add(
                new ProductVariantDetachedContent(
                    firstVariant.Key,
                    detachedContentType,
                    "en-US",
                    new DetachedDataValuesCollection(
                        new[]
                            {
                                new KeyValuePair<string, string>(
                                    "description",
                                    "\"<p><span>US ENGLISH VARIANT 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
                });

            firstVariant.DetachedContents.Add(
                new ProductVariantDetachedContent(
                    firstVariant.Key,
                    detachedContentType,
                    "en-GB",
                    new DetachedDataValuesCollection(
                        new[]
                            {
                                new KeyValuePair<string, string>(
                                    "description",
                                    "\"<p><span>GB ENGLISH VARIANT 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
                });

            _productService.Save(this._original);
        }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DetachedContentApiController"/> class.
        /// </summary>
        /// <param name="merchelloContext">
        /// The <see cref="IMerchelloContext"/>.
        /// </param>
        /// <param name="umbracoContext">
        /// The <see cref="UmbracoContext"/>.
        /// </param>
        public DetachedContentApiController(IMerchelloContext merchelloContext, UmbracoContext umbracoContext)
            : base(merchelloContext, umbracoContext)
        {
            if (ApplicationContext == null) throw new NotFiniteNumberException("Umbraco ApplicationContext is null");

            _contentTypeService = ApplicationContext.Services.ContentTypeService;

            _detachedContentTypeService = ((ServiceContext)merchelloContext.Services).DetachedContentTypeService;

            this.Initialize();
        }
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProductContentFactory"/> class.
 /// </summary>
 /// <param name="storeSettingService">
 /// The store setting service.
 /// </param>
 /// <param name="detachedContentTypeService">
 /// The detached content type service.
 /// </param>
 internal ProductContentFactory(IStoreSettingService storeSettingService, IDetachedContentTypeService detachedContentTypeService)
 {
     _storeSettingService        = storeSettingService;
     _detachedContentTypeService = detachedContentTypeService;
     this.Initialize();
 }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProductContentFactory"/> class.
 /// </summary>
 /// <param name="storeSettingService">
 /// The store setting service.
 /// </param>
 /// <param name="detachedContentTypeService">
 /// The detached content type service.
 /// </param>
 internal ProductContentFactory(IStoreSettingService storeSettingService, IDetachedContentTypeService detachedContentTypeService)
 {
     _storeSettingService = storeSettingService;
     _detachedContentTypeService = detachedContentTypeService;
     this.Initialize();
 }
コード例 #7
0
 /// <summary>
 /// The detached content type service on deleting.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="e">
 /// The e.
 /// </param>
 private void DetachedContentTypeServiceOnDeleting(IDetachedContentTypeService sender, DeleteEventArgs<IDetachedContentType> e)
 {
     foreach (var dc in e.DeletedEntities)
     {
         // remove detached content from products
         var products = MerchelloContext.Current.Services.ProductService.GetByDetachedContentType(dc.Key);
         MerchelloContext.Current.Services.ProductService.RemoveDetachedContent(products, dc.Key);
     }
 }
コード例 #8
0
        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,
                    detachedContentType,
                    "en-GB",
                    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
            });

            var firstVariant = _original.ProductVariants.First();

            firstVariant.DetachedContents.Add(
                new ProductVariantDetachedContent(
                    firstVariant.Key,
                    detachedContentType,
                    "en-US",
                    new DetachedDataValuesCollection(
                        new[]
            {
                new KeyValuePair <string, string>(
                    "description",
                    "\"<p><span>US ENGLISH VARIANT 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
            });

            firstVariant.DetachedContents.Add(
                new ProductVariantDetachedContent(
                    firstVariant.Key,
                    detachedContentType,
                    "en-GB",
                    new DetachedDataValuesCollection(
                        new[]
            {
                new KeyValuePair <string, string>(
                    "description",
                    "\"<p><span>GB ENGLISH VARIANT 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
            });

            _productService.Save(this._original);
        }