Skip to content

Instantly share code, notes, and snippets.

@smarenich smarenich/ContractsDemo.cs
Last active Feb 24, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.