public static void TestAddUpdateInventory1() { InventoryController iss = new InventoryController(WS_USERNAME, WS_PASSWORD); //get a inventory object (before modifying...) VinInventory.Response2 iss_response2 = new VinInventory.Response2(); iss_response2 = iss.IS_SearchInventoryBySKU2("746969c"); //make a change if ((bool)iss_response2.IsSuccessful) { if (iss_response2.RecordCount == 1) { //CHANGE THE VALUE HERE... double?inventoryCount = 23d; iss_response2.Inventory[0].CurrentInventory = inventoryCount; } //for (int i = 0; i < iss_response2.Inventory.Length; i++) //{ // //CHANGE THE VALUE HERE... // double? inventoryCount = 999d; // iss_response2.Inventory[i].CurrentInventory = inventoryCount; //} } //update the inventory VinInventory.Response1 iss_response1 = new VinInventory.Response1(); //***************************************************************** iss_response1 = iss.IS_UpdateInventory(iss_response2.Inventory[0]); //***************************************************************** //print if was success Console.WriteLine("The INVENTORY update for {0} was a success: {1}", iss_response2.Inventory[0].SKU, iss_response1.IsSuccessful); }
//------ //CONSTRUCTOR public InventoryController(string username, string password) { //INSTANTIATE OBJECTS conn = new MyConnection(username, password); //Establish a connection when an object is created iss = new VinInventory.InventoryServiceService(); //create INVENTORY SERVICES object //-------------- //SEARCH INVENTORY iss_request2 = new VinInventory.Request2(); //create REQUEST object iss_request2.Security = new VinInventory.Security(); //Security settings for connection (to VIN65 web service) iss_response2 = new VinInventory.Response2(); //create RESPONSE object (array of Products[...]) //SET USERNAME and PASSWORD iss_request2.Security.Username = conn.Ws_Username; //set global username //ps_request.Security.Username = "******"; iss_request2.Security.Password = conn.Ws_Password; //set global password //ps_request.Security.Password = "******"; //-------------- //-------------- //UPDATE INVENTORY iss_request1 = new VinInventory.Request1(); //create REQUEST object iss_request1.Security = new VinInventory.Security(); //Security settings for connection (to VIN65 web service) iss_response1 = new VinInventory.Response1(); //create RESPONSE object (array of Products[...]) //SET USERNAME and PASSWORD iss_request1.Security.Username = conn.Ws_Username; //set global username //ps_request.Security.Username = "******"; iss_request1.Security.Password = conn.Ws_Password; //set global password //ps_request.Security.Password = "******"; //-------------- }
public static void TestSearchInventory1() { InventoryController iss = new InventoryController(WS_USERNAME, WS_PASSWORD); //---- VinInventory.Response2 iss_response1 = new VinInventory.Response2(); iss_response1 = iss.IS_SearchInventoryBySKU2("746969c"); VinInventory.Inventory[] inventoryList = iss_response1.Inventory; Console.WriteLine("------"); Console.WriteLine("INVENTORY"); for (int i = 0; i < inventoryList.Length; i++) { Utility.Utility.DumpProperties(inventoryList[i]); //Console.WriteLine("SKU: " + inventoryList[i].SKU); //Console.WriteLine("Current Inventory: " + inventoryList[i].CurrentInventory); } Console.WriteLine("------"); }