private static void RunSample(string username, string password, string accountId, string language, string country, string productId, string storeCode) { // Connect to the service ContentForShoppingService service = new ContentForShoppingService("Inventory-Sample", accountId); service.setUserCredentials(username, password); // Create a new inventory entry InventoryEntry entry = new InventoryEntry(); entry.Availability = "in stock"; entry.Price = new Price("usd", "250.00"); entry.Quantity = 1000; entry.SalePrice = new SalePrice("usd", "199.90"); entry.SalePriceEffectiveDate = "2012-01-09 2012-01-13"; // Add necessary EditUri bool setEditUri = true; entry = service.AddLocalId(entry, language, country, productId, storeCode, setEditUri); // Update the product we just constructed Console.WriteLine("Updating local product"); InventoryEntry updated = service.UpdateInventoryEntry(entry); // Attempt a similar update via batch updated.Quantity = 900; updated.Price = new Price("usd", "240.00"); updated = service.AddLocalId(updated, language, country, productId, storeCode); InventoryFeed feed = service.UpdateInventoryFeed(new List<InventoryEntry> {updated}); // Display title and id for each local product Console.WriteLine("Listing all inventory returned"); foreach (InventoryEntry m in feed.Entries) { Console.WriteLine("Locsl Product: " + m.Title.Text + " (" + m.EditUri + ")"); } }
/// <summary> /// Updates an existing inventory entry with the new values /// /// Must have EditUri set to the location of the entry. /// Consider using AddLocalId with setEditUri=true for this. /// </summary> /// <param name="entry">the entry to update</param> /// <returns>the updated entry returned by the server</returns> public InventoryEntry UpdateInventoryEntry(InventoryEntry entry) { return base.Update(entry); }
/// <summary> /// Adds a local ID to an entry /// </summary> /// <param name="entry">the entry to add an ID to</param> /// <param name="language">The language for the entry.</param> /// <param name="country">The target country of the entry.</param> /// <param name="productId">The unique identifier for the product in the given locale.</param> /// <param name="storeCode">The store code for this local product.</param> /// <returns>the entry with ID added</returns> public InventoryEntry AddLocalId(InventoryEntry entry, string language, string country, string productId, string storeCode) { return AddLocalId(entry, language, country, productId, storeCode, false, this.accountId); }
/// <summary> /// Adds a local ID to an entry /// </summary> /// <param name="entry">the entry to add an ID to</param> /// <param name="language">The language for the entry.</param> /// <param name="country">The target country of the entry.</param> /// <param name="productId">The unique identifier for the product in the given locale.</param> /// <param name="storeCode">The store code for this local product.</param> /// <param name="setEditUri">Boolean to determine which attribute will be set.</param> /// <param name="accountId">The account ID of the user.</param> /// <returns>the entry with ID added</returns> public InventoryEntry AddLocalId(InventoryEntry entry, string language, string country, string productId, string storeCode, bool setEditUri, string accountId) { string localProductId = CreateProductIdentifier("local", language, country, productId); string localProductPath = storeCode + "/items/" + localProductId; Uri localProductUri = CreateUri(accountId, "inventory", null, localProductPath); if (setEditUri) { entry.EditUri = localProductUri; } else { entry.Id = new AtomId(localProductUri.ToString()); } return entry; }
/// <summary> /// Updates an existing inventory entry with the new values /// /// Must have EditUri set to the location of the entry. /// Consider using AddLocalId with setEditUri=true for this. /// </summary> /// <param name="entry">the entry to update</param> /// <returns>the updated entry returned by the server</returns> public InventoryEntry UpdateInventoryEntry(InventoryEntry entry) { return(base.Update(entry)); }
/// <summary> /// Adds a local ID to an entry /// </summary> /// <param name="entry">the entry to add an ID to</param> /// <param name="language">The language for the entry.</param> /// <param name="country">The target country of the entry.</param> /// <param name="productId">The unique identifier for the product in the given locale.</param> /// <param name="storeCode">The store code for this local product.</param> /// <returns>the entry with ID added</returns> public InventoryEntry AddLocalId(InventoryEntry entry, string language, string country, string productId, string storeCode) { return(AddLocalId(entry, language, country, productId, storeCode, false, this.accountId)); }