Example #1
0
        /// <summary>
        /// Creates a new product that can be used to test the Collect API.
        /// </summary>
        /// <returns>The new product.</returns>
        public static async Task<ShopifyProduct> CreateProduct()
        {
            var service = new ShopifyProductService(Utils.MyShopifyUrl, Utils.AccessToken);
            var product = new ShopifyProduct()
            {
                CreatedAt = DateTime.UtcNow,
                Title = "Burton Custom Freestlye 151",
                Vendor = "Burton",
                BodyHtml = "<strong>Good snowboard!</strong>",
                ProductType = "Snowboard",
                Images = new List<ShopifyProductImage> { new ShopifyProductImage { Attachment = "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" } },
            };

            return await service.CreateAsync(product);
        }
Example #2
0
        /// <summary>
        /// Creates a new product that can be used to test the Collect API.
        /// </summary>
        /// <returns>The new product.</returns>
        public static async Task <ShopifyProduct> CreateProduct()
        {
            var service = new ShopifyProductService(Utils.MyShopifyUrl, Utils.AccessToken);
            var product = new ShopifyProduct()
            {
                CreatedAt   = DateTime.UtcNow,
                Title       = "Burton Custom Freestlye 151",
                Vendor      = "Burton",
                BodyHtml    = "<strong>Good snowboard!</strong>",
                ProductType = "Snowboard",
                Images      = new List <ShopifyProductImage> {
                    new ShopifyProductImage {
                        Attachment = "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
                    }
                },
            };

            return(await service.CreateAsync(product));
        }
Example #3
0
        internal static ShopifyProduct SaveProductOnShopify(ShopifyProductService shopifyProductService, ShopifyProduct shopifyProduct)
        {
            var saveShopifyProduct = default(ShopifyProduct);

            ShopifyCall.ExecuteCall(delegate()
            {
                var task = default(Task <ShopifyProduct>);

                if (shopifyProduct.Id == null)
                {
                    task = shopifyProductService.CreateAsync(shopifyProduct);
                }
                else
                {
                    task = shopifyProductService.UpdateAsync(shopifyProduct);
                }

                task.Wait();

                saveShopifyProduct = task.Result;
            });

            return(saveShopifyProduct);
        }