public void Execute(ConfirmDisbursementNoteCommand command)
        {
            _log.InfoFormat("Execute {1} - Command Id {0} ", command.CommandId, command.GetType().ToString());
            try
            {
                
                bool already_Exist = _documentRepository.GetById(command.DocumentId) != null;

                if (!already_Exist)
                    return;
                DisbursementNote disbursementNote = _documentRepository.GetById(command.DocumentId) as DisbursementNote;
                disbursementNote.Confirm();
                //save the order            
                _documentRepository.Save(disbursementNote);

                foreach (var lineItem in disbursementNote.LineItems)
                {
                    ////on the server debit issuer cc
                    //_inventoryWorkflow.InventoryAdjust(disbursementNote.DocumentIssuerCostCentre.Id, lineItem.Product.Id,
                    //                                   -lineItem.Qty, DocumentType.DispatchNote, disbursementNote.Id,
                    //                                   disbursementNote.DocumentDateIssued);
                    ////credit recipient cc
                    //_inventoryWorkflow.InventoryAdjust(disbursementNote.DocumentRecipientCostCentre.Id, lineItem.Product.Id,
                    //                                   lineItem.Qty, DocumentType.DispatchNote, disbursementNote.Id,
                    //                                   disbursementNote.DocumentDateIssued);
                }

            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Error Execute {1} - Command Id {0} ", command.CommandId, command.GetType());
                _log.Error("ConfirmDisbursementNoteCommandHandler exception", ex);
                throw;
            }
        }
        public void SubmitChanges(DisbursementNote document,BasicConfig config )
        {
            //send commands
            var coc = new CreateDisbursementNoteCommand(
                Guid.NewGuid(),                
                document.Id,              
                document.DocumentIssuerUser.Id,               
                config.CostCentreId,               
                0,               
                document.DocumentIssuerCostCentreApplicationId,               
                document.DocumentIssuerCostCentre.Id,               
                document.DocumentRecipientCostCentre.Id, 
                document.DocumentIssuerUser.Id,
                document.DocumentParentId,document.DocumentDateIssued, 
                document.DocumentReference
             );

            _commandRouter.RouteDocumentCommand(coc);
            _auditLogWFManager.AuditLogEntry("Disbursment Note", string.Format("Created Disbursement Note document: {0}", document.Id));

            foreach (var item in document.LineItems)
            {
                var ali = new AddDisbursementNoteLineItemCommand(
                    Guid.NewGuid(),
                    document.Id,
                    document.DocumentIssuerUser.Id,
                    document.DocumentIssuerCostCentre.Id,
                    0,
                    config.CostCentreApplicationId,
                    0,
                    item.Product.Id,
                    item.Qty,
                    item.Value,document.DocumentParentId);
                _commandRouter.RouteDocumentCommand(ali);
                _auditLogWFManager.AuditLogEntry("Disbursment Note", string.Format("Added Product: {1}; Quantity: {2}; Value: {3}; to Disbursement Note document: {0}", document.Id,item.Product.Description,item.Qty,item.Value));

            }

            var co = new ConfirmDisbursementNoteCommand(Guid.NewGuid(), document.Id,
                document.DocumentIssuerUser.Id,
                document.DocumentIssuerCostCentre.Id, 0,
                config.CostCentreApplicationId,document.DocumentParentId);

            _commandRouter.RouteDocumentCommand(co);
            _auditLogWFManager.AuditLogEntry("Disbursment Note", string.Format("Confirmed Disbursement Note document: {0}", document.Id));
        }