Shipments - Add, Fetch, Filter

Sample code to show how to list Shipments for a selected location

Shipment ship;

ship = Shipment.NewShipment(ShipmentStatusType.NewDirectShip);
ship.FromLocationType = SourceType.BranchOffice;
ship.FromStockingLocationID = <FromStockingLocationID>;
ship.ToLocationType = SourceType.JobSite;
ship.ToStockingLocationID = <ToStockingLocationID>;
ship.ShipmentProducts["A013010", Guid.Empty].SentQuantity = 100;
ship.ShipmentProducts["B013010", Guid.Empty].SentQuantity = 100;
ship.PlannedShipDate = new DateTime(2015, 9, 19).ToShortDateString();
ship.Save();

ship = Shipment.NewShipment(ShipmentStatusType.NewDirectShip);
ship.FromLocationType = SourceType.BranchOffice;
ship.FromStockingLocationID = <FromStockingLocationID>;
ship.ToLocationType = SourceType.JobSite;
ship.ToStockingLocationID = <ToStockingLocationID>;
ship.ShipmentProducts["A013010", Guid.Empty].SentQuantity = 100;
ship.ShipmentProducts["B013010", Guid.Empty].SentQuantity = 100;
ship.PlannedShipDate = new DateTime(2015, 12, 11).ToShortDateString();
ship.Save();

ship = Shipment.NewShipment(ShipmentStatusType.NewDirectShip);
ship.FromLocationType = SourceType.BranchOffice;
ship.FromStockingLocationID = <FromStockingLocationID>;
ship.ToLocationType = SourceType.JobSite;
ship.ToStockingLocationID = <ToStockingLocationID>;
ship.ShipmentProducts["A013010", Guid.Empty].SentQuantity = 100;
ship.ShipmentProducts["B013010", Guid.Empty].SentQuantity = 100;
ship.PlannedShipDate = new DateTime(2016, 2, 11).ToShortDateString();
ship.Save();

ship = Shipment.NewShipment(ShipmentStatusType.NewDirectShip);
ship.FromLocationType = SourceType.BranchOffice;
ship.FromStockingLocationID = <FromStockingLocationID>;
ship.ToLocationType = SourceType.JobSite;
ship.ToStockingLocationID = <ToStockingLocationID>;
ship.ShipmentProducts["A013010", Guid.Empty].SentQuantity = 100;
ship.ShipmentProducts["B013010", Guid.Empty].SentQuantity = 100;
ship.PlannedShipDate = new DateTime(2016, 8, 19).ToShortDateString();
ship.Save();

List<Guid> stockingLocationIDs = new List<Guid>();
stockingLocationIDs.Add(<SelectedStockingLocationID>); //Add all location IDs for which the shipments are to be included

ShipmentList shipments = ShipmentList.GetShipmentListForGrid(<SelectedStockingLocationID>, //Selected location ID, to fetch shipments visible under it
	stockingLocationIDs, //List of StockingLocationIDs for which the shipments are to be fetched
	true, //Flag to include/exclude by active status of locations
	ShipmentStatusType.ShowAll, //Flag to include/exclude by shipment status 
	false, //Flag to include/exclude voided shipments
	6, //No of months from current to fetch the shipments for, 0 for all
	true, //Flag to include/exclude by inactive status of scaffold tags
	PartnerTypes.BranchOffice); //Selected location type


List<ShipmentListItem> shipmentsByDate = shipments.Where(s => s.PlannedShipDate.Date == new DateTime(2016, 8, 18)).ToList();          
return DataPortal.Fetch<AvontusPermissionView>(new SingleCriteria<AvontusPermissionView, Guid>(Guid.Empty));

How can I create a new reservation (ShipmentStatusType.NewReservation) instead of a direct shipment? When using the code above with ShipmentStatusType.NewReservation the ship.Save() will fail.

Here is the updated sample code to create a reservation -

Shipment ship;

ship = Shipment.NewShipment(ShipmentStatusType.NewReservation);
ship.FromLocationType = SourceType.BranchOffice;
ship.FromStockingLocationID = ;
ship.ToLocationType = SourceType.JobSite;
ship.ToStockingLocationID = ;
ship.ShipmentProducts[“A013010”, Guid.Empty].ReservedQuantity = 100;
ship.ShipmentProducts[“B013010”, Guid.Empty].ReservedQuantity = 100;
ship.PlannedShipDate = new DateTime(2015, 9, 19).ToShortDateString();
ship.Save();