Example 57 : Creating a consignment with nominal data
This example will create a single consignment in the DM system by using the smallest amount of data possible.
using System; using System.Collections.Generic; using System.Text; namespace Com.MetaPack.DeliveryManager.Examples.CSharp { public class Example57 : DMExample { public override void Run() { /* * Create an empty consignment object, and specify the order number. */ Consignment consignment = new Consignment(); consignment.orderNumber = "EXAMPLE-57" ; consignment.consignmentLevelDetailsFlag = true; /* * Specify the warehouse, and the source address. Normally, the address is the * address of the warehouse, but not necessarily. All these pieces of information are required. */ consignment.senderCode = "DEFAULT"; consignment.senderName = "My default warehouse"; Address senderAddress = new Address(); senderAddress.line1 ="12-14 Laystall Street"; senderAddress.line2 = "London" ; senderAddress.countryCode = "GBR" ; senderAddress.postCode = "EC1R 4PF" ; consignment.senderAddress = senderAddress; /* * The destination. All these pieces of information are required. */ consignment.recipientName = "The Queen"; Address recipientAddress = new Address(); recipientAddress.line1 ="Buckingham Palace"; recipientAddress.line2 = "London"; recipientAddress.countryCode = "GBR"; recipientAddress.postCode = "SW1A 1AA"; consignment.recipientAddress = recipientAddress; /* * Now we specify how many parcels there are, and specify the consignment weight. * Both of these are mandatory. NB. We have also passed in an array of four parcels. * Even if you don't supply information at the parcel level, you need to do this. */ int parcelCount = 4; consignment.parcelCount = parcelCount; Parcel[] parcels = new Parcel[parcelCount ]; for( int i = 0 ; i < parcelCount ; i++ ) { parcels[ i ] = new Parcel(); } consignment.parcels = parcels; consignment.consignmentWeight = 1.56; /* * Create the consignments in DM */ Consignment[] createdConsignments = Client.ConsignmentService.createConsignments(new Consignment[] { consignment }); /* * Iterate through the responses to see what codes the consignments were given. In this example, * there should be only one. */ for( int i = 0 ; i < createdConsignments.Length ; i++ ) { System.Diagnostics.Debug.WriteLine( "Consignment " + createdConsignments[i].orderNumber + " was created with code " + createdConsignments[i].consignmentCode ); } } } }

