public void Execute(CreateInvoiceCommand command) { _log.InfoFormat("Execute {1} - Command Id {0} ", command.CommandId, command.GetType().ToString()); try { if (DocumentExists(command.DocumentId)) return; tblDocument doc = NewDocument(command, DocumentType.Invoice, command.DocumentRecipientCostCentreId); doc.InvoiceOrderId = command.OrderId; doc.SaleDiscount = command.SaleDiscount; _cokeDataContext.tblDocument.AddObject(doc); _cokeDataContext.SaveChanges(); } catch (Exception ex) { _log.ErrorFormat("Error Execute {1} - Command Id {0} ", command.CommandId, command.GetType().ToString()); _log.Error("CreateInvoiceCommandHandler exception " ,ex); throw ; } }
public void Handle(CreateInvoiceCommand command) { var order = GetOrder(); if (order != null) { order.InvoiceReference = command.DocumentReference; order.InvoiceId = command.DocumentId; } }