public void Exercise_11_2_Create_New_Product()
        {
            var productCode = "LUC-BAG-011";

            //Grouped our necessary resources for defining aspects of the new product
            var productResource = new Mozu.Api.Resources.Commerce.Catalog.Admin.ProductResource(_apiContext);
            var productTypeResource = new Mozu.Api.Resources.Commerce.Catalog.Admin.Attributedefinition.ProductTypeResource(_apiContext);
            var categoryResource = new Mozu.Api.Resources.Commerce.Catalog.Admin.CategoryResource(_apiContext);
            var productAttributeResource = new Mozu.Api.Resources.Commerce.Catalog.Admin.Attributedefinition.AttributeResource(_apiContext);
            
            //Wrap the Delete call in a try/catch in case the product doesn't exist
            try
            {
                productResource.DeleteProductAsync(productCode).Wait();
            }
            catch(Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
            }

            //Retrieve the objects for later use when constructing our product
            var monogram = productAttributeResource.GetAttributeAsync("tenant~monogram").Result;
            var purseSize = productAttributeResource.GetAttributeAsync("tenant~purse-size").Result;
            var typePurse = productTypeResource.GetProductTypesAsync(filter: "Name eq 'Purse'").Result;
            var bagCategory = categoryResource.GetCategoryAsync(2).Result;

            Assert.IsNotNull(monogram);
            Assert.IsNotNull(purseSize);
            Assert.IsNotNull(typePurse);
            Assert.IsNotNull(bagCategory);

            //Define the monogram as a ProductExtra to use when defining the Product
            var monogramContract = new Mozu.Api.Contracts.ProductAdmin.ProductExtra()
            {
                AttributeFQN = monogram.AttributeFQN
            };

            //The actual List<ProductExtra> object added to the Product Contract
            var productExtraList = new List<Mozu.Api.Contracts.ProductAdmin.ProductExtra>()
            {
                monogramContract
            };

            //Construct a List<ProductOptionValue> using the purse-size Attribute Values
            var purseSizeValuesList = new List<Mozu.Api.Contracts.ProductAdmin.ProductOptionValue>();
            //Use this option to catch each Value we want to add for this Product
            var purseSizeOptionValue = new Mozu.Api.Contracts.ProductAdmin.ProductOptionValue();
            //Include only the values specified in the if-clause within the foreach loop
            foreach(var value in purseSize.VocabularyValues)
            {
                //If we wanted to include all sizes, we would remove this if-clause
                if (value.Content.StringValue.ToLower() == "petite" || value.Content.StringValue.ToLower() == "classic")
                {
                    //We instantiate a new object each time to avoid reference errors
                    purseSizeOptionValue = new Mozu.Api.Contracts.ProductAdmin.ProductOptionValue();
                    purseSizeOptionValue.AttributeVocabularyValueDetail = value;
                    purseSizeOptionValue.Value = value.Value;
                    purseSizeValuesList.Add(purseSizeOptionValue);
                }
            }

            //Define the purse-size as a ProductOption to use when defining the Product -- we use the purseSizeValuesList to add Values for the ProdcutOption
            var purseSizeContract = new Mozu.Api.Contracts.ProductAdmin.ProductOption()
            {
                AttributeFQN = purseSize.AttributeFQN,
                Values = purseSizeValuesList
            };

            //The actual Option object added to the Product Contract
            var productOptionList = new List<Mozu.Api.Contracts.ProductAdmin.ProductOption>()
            {
                purseSizeContract
            };

            //Construct a Product contract to submit to the API
            var product = new Mozu.Api.Contracts.ProductAdmin.Product()
            {
                Content = new Mozu.Api.Contracts.ProductAdmin.ProductLocalizedContent()
                {
                    ProductName = "Api Handbag",
                    LocaleCode = "en-US"
                },
                FulfillmentTypesSupported = new List<string>() 
                {
                    "DirectShip" 
                },
                HasConfigurableOptions = true,
                IsTaxable = true,
                Extras = productExtraList,
                Options = productOptionList,
                PublishingInfo = new Mozu.Api.Contracts.ProductAdmin.ProductPublishingInfo()
                {
                    PublishedState = "Live"
                },
                PackageHeight = new Mozu.Api.Contracts.Core.Measurement()
                {
                    Unit = "in",
                    Value = 7
                },
                PackageWidth = new Mozu.Api.Contracts.Core.Measurement()
                {
                    Unit = "in",
                    Value = 3
                },
                PackageLength = new Mozu.Api.Contracts.Core.Measurement()
                {
                    Unit = "in",
                    Value = 10.25m
                },
                PackageWeight = new Mozu.Api.Contracts.Core.Measurement()
                {
                    Unit = "lbs",
                    Value = 2.25m
                },
                Price = new Mozu.Api.Contracts.ProductAdmin.ProductPrice()
                {
                    Price = 175m,
                    SalePrice = 125m
                },
                ProductUsage = "Configurable",
                ProductCode = productCode,
                //Add the ProductType "purse" that we retrieved earlier
                ProductTypeId = typePurse.Items.FirstOrDefault().Id,
                HasStandAloneOptions = false,
                InventoryInfo = new Mozu.Api.Contracts.ProductAdmin.ProductInventoryInfo()
                {
                    ManageStock = true,
                    OutOfStockBehavior = "DisplayMessage"
                },
                MasterCatalogId = 1,
                ProductInCatalogs = new List<Mozu.Api.Contracts.ProductAdmin.ProductInCatalogInfo>() 
                {
                    new Mozu.Api.Contracts.ProductAdmin.ProductInCatalogInfo()
                    { 
                        CatalogId = 1,
                        IsActive = true,
                        IsContentOverridden = false,
                        IsPriceOverridden = false,
                        IsseoContentOverridden = false,
                        Content = new Mozu.Api.Contracts.ProductAdmin.ProductLocalizedContent()
                        {
                            LocaleCode = "en-US",
                            ProductName = "Api Handbag",
                        },
                        ProductCategories = new List<Mozu.Api.Contracts.ProductAdmin.ProductCategory>()
                        {
                            new Mozu.Api.Contracts.ProductAdmin.ProductCategory()
                            {
                                //Add the product to the "bag" category using what we retrieved earlier
                                CategoryId =  bagCategory.Id.Value,
                            }
                        }
                    }
                },

            };

            //The API call used to add a new product
            var newProduct = productResource.AddProductAsync(product).Result;

            var variationResource = new Mozu.Api.Resources.Commerce.Catalog.Admin.Products.ProductVariationResource(_apiContext);


        }
        public void Exercise_11_2_Create_New_Product()
        {
            var productCode = "LUC-BAG-011";

            //Grouped our necessary resources for defining aspects of the new product
            var productResource          = new Mozu.Api.Resources.Commerce.Catalog.Admin.ProductResource(_apiContext);
            var productTypeResource      = new Mozu.Api.Resources.Commerce.Catalog.Admin.Attributedefinition.ProductTypeResource(_apiContext);
            var categoryResource         = new Mozu.Api.Resources.Commerce.Catalog.Admin.CategoryResource(_apiContext);
            var productAttributeResource = new Mozu.Api.Resources.Commerce.Catalog.Admin.Attributedefinition.AttributeResource(_apiContext);

            //Wrap the Delete call in a try/catch in case the product doesn't exist
            try
            {
                productResource.DeleteProductAsync(productCode).Wait();
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
            }

            //Retrieve the objects for later use when constructing our product
            var monogram    = productAttributeResource.GetAttributeAsync("tenant~monogram").Result;
            var purseSize   = productAttributeResource.GetAttributeAsync("tenant~purse-size").Result;
            var typePurse   = productTypeResource.GetProductTypesAsync(filter: "Name eq 'Purse'").Result;
            var bagCategory = categoryResource.GetCategoryAsync(2).Result;

            Assert.IsNotNull(monogram);
            Assert.IsNotNull(purseSize);
            Assert.IsNotNull(typePurse);
            Assert.IsNotNull(bagCategory);

            //Define the monogram as a ProductExtra to use when defining the Product
            var monogramContract = new Mozu.Api.Contracts.ProductAdmin.ProductExtra()
            {
                AttributeFQN = monogram.AttributeFQN
            };

            //The actual List<ProductExtra> object added to the Product Contract
            var productExtraList = new List <Mozu.Api.Contracts.ProductAdmin.ProductExtra>()
            {
                monogramContract
            };

            //Construct a List<ProductOptionValue> using the purse-size Attribute Values
            var purseSizeValuesList = new List <Mozu.Api.Contracts.ProductAdmin.ProductOptionValue>();
            //Use this option to catch each Value we want to add for this Product
            var purseSizeOptionValue = new Mozu.Api.Contracts.ProductAdmin.ProductOptionValue();

            //Include only the values specified in the if-clause within the foreach loop
            foreach (var value in purseSize.VocabularyValues)
            {
                //If we wanted to include all sizes, we would remove this if-clause
                if (value.Content.StringValue.ToLower() == "petite" || value.Content.StringValue.ToLower() == "classic")
                {
                    //We instantiate a new object each time to avoid reference errors
                    purseSizeOptionValue = new Mozu.Api.Contracts.ProductAdmin.ProductOptionValue();
                    purseSizeOptionValue.AttributeVocabularyValueDetail = value;
                    purseSizeOptionValue.Value = value.Value;
                    purseSizeValuesList.Add(purseSizeOptionValue);
                }
            }

            //Define the purse-size as a ProductOption to use when defining the Product -- we use the purseSizeValuesList to add Values for the ProdcutOption
            var purseSizeContract = new Mozu.Api.Contracts.ProductAdmin.ProductOption()
            {
                AttributeFQN = purseSize.AttributeFQN,
                Values       = purseSizeValuesList
            };

            //The actual Option object added to the Product Contract
            var productOptionList = new List <Mozu.Api.Contracts.ProductAdmin.ProductOption>()
            {
                purseSizeContract
            };

            //Construct a Product contract to submit to the API
            var product = new Mozu.Api.Contracts.ProductAdmin.Product()
            {
                Content = new Mozu.Api.Contracts.ProductAdmin.ProductLocalizedContent()
                {
                    ProductName = "Api Handbag",
                    LocaleCode  = "en-US"
                },
                FulfillmentTypesSupported = new List <string>()
                {
                    "DirectShip"
                },
                HasConfigurableOptions = true,
                IsTaxable      = true,
                Extras         = productExtraList,
                Options        = productOptionList,
                PublishingInfo = new Mozu.Api.Contracts.ProductAdmin.ProductPublishingInfo()
                {
                    PublishedState = "Live"
                },
                PackageHeight = new Mozu.Api.Contracts.Core.Measurement()
                {
                    Unit  = "in",
                    Value = 7
                },
                PackageWidth = new Mozu.Api.Contracts.Core.Measurement()
                {
                    Unit  = "in",
                    Value = 3
                },
                PackageLength = new Mozu.Api.Contracts.Core.Measurement()
                {
                    Unit  = "in",
                    Value = 10.25m
                },
                PackageWeight = new Mozu.Api.Contracts.Core.Measurement()
                {
                    Unit  = "lbs",
                    Value = 2.25m
                },
                Price = new Mozu.Api.Contracts.ProductAdmin.ProductPrice()
                {
                    Price     = 175m,
                    SalePrice = 125m
                },
                ProductUsage = "Configurable",
                ProductCode  = productCode,
                //Add the ProductType "purse" that we retrieved earlier
                ProductTypeId        = typePurse.Items.FirstOrDefault().Id,
                HasStandAloneOptions = false,
                InventoryInfo        = new Mozu.Api.Contracts.ProductAdmin.ProductInventoryInfo()
                {
                    ManageStock        = true,
                    OutOfStockBehavior = "DisplayMessage"
                },
                MasterCatalogId   = 1,
                ProductInCatalogs = new List <Mozu.Api.Contracts.ProductAdmin.ProductInCatalogInfo>()
                {
                    new Mozu.Api.Contracts.ProductAdmin.ProductInCatalogInfo()
                    {
                        CatalogId              = 1,
                        IsActive               = true,
                        IsContentOverridden    = false,
                        IsPriceOverridden      = false,
                        IsseoContentOverridden = false,
                        Content = new Mozu.Api.Contracts.ProductAdmin.ProductLocalizedContent()
                        {
                            LocaleCode  = "en-US",
                            ProductName = "Api Handbag",
                        },
                        ProductCategories = new List <Mozu.Api.Contracts.ProductAdmin.ProductCategory>()
                        {
                            new Mozu.Api.Contracts.ProductAdmin.ProductCategory()
                            {
                                //Add the product to the "bag" category using what we retrieved earlier
                                CategoryId = bagCategory.Id.Value,
                            }
                        }
                    }
                },
            };

            //The API call used to add a new product
            var newProduct = productResource.AddProductAsync(product).Result;

            var variationResource = new Mozu.Api.Resources.Commerce.Catalog.Admin.Products.ProductVariationResource(_apiContext);
        }