Ejemplo n.º 1
0
        /// <summary>
        /// Converts your internal Product object into a Ventata Product.
        /// </summary>
        /// <param name="product">An instance of your internal Product object</param>
        /// <param name="strategy">What Pricing Strategy would you like to use?</param>
        /// <param name="DateAvailable">[Limited Supply Only] When will the sale start?</param>
        /// <param name="DateExpires">[Limited Supply Only] When will the sale end?</param>
        /// <returns></returns>
        public static VentataProduct ConvertProduct(Product product, string strategy, DateTime? DateAvailable = null, DateTime? DateExpires = null)
        {
            VentataProduct productToReturn = new VentataProduct();

            //This is where we keep your PK in our system for easy lookup
            productToReturn.StoreCode = product.Id.ToString();

            //Map internal Product to VentataProduct
            productToReturn.Cost = product.Cost;
            productToReturn.CurrentSupply = product.Supply;
            productToReturn.DateCreated = product.DateCreated;
            productToReturn.Description = product.DescrLong;
            productToReturn.MANUCODE = product.ManufacturerNo;
            productToReturn.MaxPrice = product.Price * 1.5m;
            productToReturn.MinPrice = product.MAP;
            productToReturn.Name = product.Name;
            productToReturn.Price = product.Price;
            productToReturn.SKU = product.SKU;

            //Set Strategy
            productToReturn.Strategy = strategy.ToString();

            //Limited Supply Mappings
            if (DateAvailable.HasValue && DateExpires.HasValue)
            {
                productToReturn.DateAvailable = DateAvailable.Value;
                productToReturn.DateExpires = DateExpires.Value;
            }

            return productToReturn;
        }
Ejemplo n.º 2
0
        public VentataProduct Create(VentataProduct product)
        {
            VentataProduct productWithId = RestHelper.CallResource(
                "POST", String.Format("{0}?ApiKey={1}",
                    "product",
                    storeApiKey), product.ToJSON() //we are going to POST to Products with the new product information
                ).FromJSON<VentataProduct>();  //then we convert it the JSON to a Ventata Product (to access the Id)

            return productWithId;
        }