Skip to content

Instantly share code, notes, and snippets.

@smarenich
Last active February 24, 2016 09:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smarenich/bc1a3ce584a0b0900edc to your computer and use it in GitHub Desktop.
Save smarenich/bc1a3ce584a0b0900edc to your computer and use it in GitHub Desktop.
static void Main(string[] args)
{
using (DefaultSoapClient client = new DefaultSoapClient())
{
client.Endpoint.Address = new System.ServiceModel.EndpointAddress("https://localhost/demo/entity/Default/5.30.001");
client.Login("admin", "123", "Demo", null, null);
Console.WriteLine("Get all Stock Items");
//retrieveAllEntities force system to retrive details and linked entities
Entity[] items = client.GetList(new StockItem(), false);
foreach (StockItem c in items)
{
Console.WriteLine(c.InventoryID.Value);
}
Console.WriteLine("Get a specific item with search");
//Throught StringSearch you can specify complext searching conditions
StockItem legoitem = client.Get(new StockItem() { InventoryID = new StringSearch() { Condition = StringCondition.Contains, Value = "AALEGO" } }) as StockItem;
Console.WriteLine(legoitem.InventoryID.Value);
Console.WriteLine(legoitem.Description.Value);
Console.WriteLine("Creating of new Stock Item");
StockItem item = new StockItem();
item.InventoryID = new StringValue() { Value = "MyItem" };
item.Description = new StringValue() { Value = "My Item Description" };
item.ItemClass = new StringValue() { Value = "CONSUMER" };
item.Volume = new DecimalValue() { Value = 5 };
item.Volume = new DecimalValue() { Value = 10 };
item.VendorDetails = new StockItemVendorDetail[]
{
new StockItemVendorDetail
{
VendorID = new StringValue { Value = "AAVENDOR" },
},
new StockItemVendorDetail
{
VendorID = new StringValue { Value = "ACITAISYST" },
},
};
item = (StockItem)client.Put(item);
Console.WriteLine("Stock was created.");
Console.WriteLine("Updating Stock Item");
item.Description.Value = item.Description.Value + " Updated";
client.Put(item);
Console.WriteLine("Stock was updated.");
Console.WriteLine("Deleting Stock Item");
client.Delete(item);
Console.WriteLine("Stock was deleted.");
client.Logout();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment