/// <summary> /// Convenience function for running tests. Creates an object and automatically adds it to the queue for deleting after tests finish. /// </summary> public async Task <Collect> Create(bool skipAddToCreatedList = false) { // Create a product to use with these tests. var product = await ProductService.CreateAsync(new ShopifySharp.Product() { CreatedAt = DateTime.UtcNow, Title = "Burton Custom Freestlye 151", Vendor = "Burton", BodyHtml = "<strong>Good snowboard!</strong>", ProductType = "Snowboard", Handle = Guid.NewGuid().ToString(), Images = new List <ProductImage> { new ProductImage { Attachment = "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" } }, PublishedScope = "published" }); var obj = await CollectService.CreateAsync(new Collect() { CollectionId = CollectionId, ProductId = product.Id.Value, }); if (!skipAddToCreatedList) { Created.Add(obj); } return(obj); }
private async void AddCollect(long collectionId, long productId) { var service = new CollectService(shopifyUrl, shopifyTokenAcces); var collect = new Collect() { CollectionId = collectionId, ProductId = productId }; await service.CreateAsync(collect); }
static public Collect AddProductToCollection(Product p, string collection) { Collect retVal = null; if (p.Id.HasValue) { collection = collection.Trim(); IEnumerable <CustomCollection> customs = CustomCollectionService.ListAsync().Result; CustomCollection cc = customs.FirstOrDefault(c => c.Title == collection); if (cc == null) { cc = CreateCustomCollection(collection); } Collect collect = new Collect() { ProductId = p.Id.Value, CollectionId = cc.Id.Value }; retVal = CollectService.CreateAsync(collect).Result; } return(retVal); }