Esempio n. 1
0
 /// <summary>
 /// generate product object
 /// </summary>
 /// <param name="productType"></param>
 /// <returns></returns>
 public static Product GenerateProduct(ProductType productType)
 {
     List<string> attributeFQNs = new List<string>();
     List<ProductExtra> extras = null;
     List<ProductProperty> properties = null;
     List<ProductOption> options = null;
     if (productType.Extras != null)
     {
         foreach (var extra in productType.Extras)
         {
             if (!attributeFQNs.Contains(extra.AttributeFQN))
             {
                 if (extras == null)
                     extras = new List<ProductExtra>();
                 extras.Add(GenerateProductExtra(extra));
                 attributeFQNs.Add(extra.AttributeFQN);
             }
         }
     }
     if (productType.Properties != null)
     {
         foreach (var property in productType.Properties)
         {
             if (!attributeFQNs.Contains(property.AttributeFQN))
             {
                 if (properties == null)
                     properties = new List<ProductProperty>();
                 properties.Add(GenerateProductProperty(property));
                 attributeFQNs.Add(property.AttributeFQN);
             }
         }
     }
     if (productType.Options != null)
     {
         foreach (var option in productType.Options)
         {
             if (!attributeFQNs.Contains(option.AttributeFQN))
             {
                 if (options == null)
                     options = new List<ProductOption>();
                 options.Add(GenerateProductOption(option));
                 attributeFQNs.Add(option.AttributeFQN);
             }
         }
     }
     return GenerateProduct(productType.Id, extras, options, properties);
 }
Esempio n. 2
0
 /// <summary>
 /// generate product object
 /// </summary>
 /// <param name="name"></param>
 /// <param name="price"></param>
 /// <param name="salep"></param>
 /// <param name="stock"></param>
 /// <param name="productType"></param>
 /// <param name="weight"></param>
 /// <returns></returns>
 public static Product GenerateProduct(string name, decimal price,
                                                              decimal salep, int stock, ProductType productType,
                                                              decimal weight)
 {
     var pd = GenerateProduct(productType);
     pd.Content.ProductName = name;
     pd.Price = GenerateProductPrice(price: price, salePrice: salep);
     pd.PackageWeight = GenerateMeasurement("lbs", weight);
     return pd;
 }
        public void AddProductTypeTest()
        {
            var productType = new ProductType
            {
                GoodsType = "Physical",
                Name = "test34",
                MasterCatalogId = 1,
                ProductUsages = new List<String> {"Standard", "Configurable", "Component"},
            };

            var result = ProductTypeFactory.AddProductType(ApiMsgHandler, productType);
        }