Hey Keith - this one is something on my to do to make easier. At the moment, the only way to do it is to walk up the graph.
If you are running this in a controller or something that references to Merchello.Web:
// assuming you have the IShipment
var shipment = [from somewhere];
var merchello = new MerchelloHelper();
// Every line item in the shipment will have a "ContainerKey" which, in this case is the OrderKey
var item = shipment.Items.FirstOrDefault(x => !x.ContainerKey.Equals(Guid.Empty));
var order = merchello.Query.Order.GetByKey(item.ContainerKey);
var invoice = merchello.Query.Invoice.GetByKey(order.InvoiceKey);
If you are doing something in a console app or test, you will need to do the same thing but with the respective services.
var order = MerchelloContext.Current.Services.OrderService.GetByKey(item.ContainerKey);
var invoice = ...
How to get to an IInvoice record, given an IShipment
How do I retrieve the related invoice, given a shipment instance?
Hey Keith - this one is something on my to do to make easier. At the moment, the only way to do it is to walk up the graph.
If you are running this in a controller or something that references to Merchello.Web:
If you are doing something in a console app or test, you will need to do the same thing but with the respective services.
is working on a reply...