public void SubmitChanges(PaymentNote document, BasicConfig config) { int sequence = 0; var envelope = new CommandEnvelope(); envelope.Initialize(document); List<DocumentCommand> commandsToExecute = document.GetDocumentCommandsToExecute(); var createCommand = commandsToExecute.OfType<CreateCommand>().FirstOrDefault(); if (createCommand != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, createCommand)); _auditLogWFManager.AuditLogEntry("PaymentNote", string.Format("Created PaymentNote: {0}; From: {1}; To: {2}", document.Id, document.DocumentIssuerCostCentre.Name, document.DocumentRecipientCostCentre.Name)); var lineItemCommands = commandsToExecute.OfType<AfterCreateCommand>(); foreach (var _item in lineItemCommands) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, _item)); } var co = commandsToExecute.OfType<ConfirmCommand>().FirstOrDefault(); if (co != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, co)); _commandEnvelopeRouter.RouteCommandEnvelope(envelope); _auditLogWFManager.AuditLogEntry("PaymentNote", string.Format("Confirmed PaymentNote: {0}; From: {1}; To: {2}", document.Id, document.DocumentIssuerCostCentre.Name, document.DocumentRecipientCostCentre.Name)); }
public void SubmitChanges(CommodityPurchaseNote document) { int sequence = 0; var envelope = new CommandEnvelope(); envelope.Initialize(document); List<DocumentCommand> commandsToExecute = document.GetDocumentCommandsToExecute(); CreateCommand createCommand = commandsToExecute.OfType<CreateCommand>().FirstOrDefault(); if (createCommand != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, createCommand)); //_commandRouter.RouteDocumentCommand(createCommand); List<AfterCreateCommand> lineItemCommands = commandsToExecute.OfType<AfterCreateCommand>().ToList(); foreach (var item in lineItemCommands) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, item)); // _commandRouter.RouteDocumentCommand(item); } ConfirmCommodityPurchaseCommand confirmCommand = commandsToExecute.OfType<ConfirmCommodityPurchaseCommand>().FirstOrDefault(); if (confirmCommand != null) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, confirmCommand)); // _commandRouter.RouteDocumentCommand(confirmCommand); //_notifyService.SubmitCommodityPurchase(document); } _commandEnvelopeRouter.RouteCommandEnvelope(envelope); _auditLogWFManager.AuditLogEntry("Commodity Purchase", "Created and confirmed commodity purchase note " + document.DocumentReference + "; id " + document.Id + " with " + document.LineItems.Count + " line items"); }
public void SubmitChanges(CommodityTransferNote document) { int sequence = 0; var envelope = new CommandEnvelope(); envelope.Initialize(document); var commandsToExecute = document.GetDocumentCommandsToExecute(); var createCommand = commandsToExecute.OfType<CreateCommand>().FirstOrDefault(); if (createCommand != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, createCommand)); var lineItemCommands = commandsToExecute.OfType<AfterCreateCommand>().ToList(); foreach (var item in lineItemCommands) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, item)); } var confirmCommodityDeliveryCommand = commandsToExecute.OfType<ConfirmCommodityTransferCommand>().FirstOrDefault(); if (confirmCommodityDeliveryCommand != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, confirmCommodityDeliveryCommand)); var approveCommodityTransferCommand = commandsToExecute.OfType<ApproveCommodityTransferCommand>().FirstOrDefault(); if (approveCommodityTransferCommand != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, approveCommodityTransferCommand)); var transferedCommodityStorageCommand = commandsToExecute.OfType<TransferedCommodityStorageLineItemCommand>().FirstOrDefault(); if (transferedCommodityStorageCommand != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, transferedCommodityStorageCommand)); _commandEnvelopeRouter.RouteCommandEnvelope(envelope); }
public void SubmitChanges(CreditNote document, BasicConfig config) { int sequence = 0; var envelope = new CommandEnvelope(); envelope.Initialize(document); List<DocumentCommand> commandsToExecute = document.GetDocumentCommandsToExecute(); CreateCommand createCommand= commandsToExecute.OfType<CreateCommand>().FirstOrDefault(); if (createCommand != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, createCommand)); // _commandRouter.RouteDocumentCommand(createCommand); List<AfterCreateCommand> lineItemCommands = commandsToExecute.OfType<AfterCreateCommand>().ToList(); foreach (var item in lineItemCommands) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, item)); //_commandRouter.RouteDocumentCommand(item); } ConfirmCreditNoteCommand confirmCreditNoteCommand = commandsToExecute.OfType<ConfirmCreditNoteCommand>().FirstOrDefault(); if (confirmCreditNoteCommand != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, confirmCreditNoteCommand)); // _commandRouter.RouteDocumentCommand(confirmCreditNoteCommand); _commandEnvelopeRouter.RouteCommandEnvelope(envelope); }
public void Submit(InventoryAdjustmentNote note) { int sequence = 0; var envelope = new CommandEnvelope(); envelope.Initialize(note); List<DocumentCommand> commandsToExecute = note.GetDocumentCommandsToExecute(); var createCommand = commandsToExecute.OfType<CreateCommand>().First(); if (createCommand != null) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, createCommand)); } var lineItemCommands = commandsToExecute.OfType<AfterCreateCommand>(); foreach (var _item in lineItemCommands) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, _item)); } var co = commandsToExecute.OfType<ConfirmCommand>().First(); if (co != null) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, co)); } AddToMongoDB(envelope); }
public void SubmitChanges(InventoryTransferNote document, BasicConfig config) { int sequence = 0; var envelope = new CommandEnvelope(); envelope.Initialize(document); List<DocumentCommand> commandsToExecute = document.GetDocumentCommandsToExecute(); var createCommand = commandsToExecute.OfType<CreateCommand>().First(); envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, createCommand)); //_commandRouter.RouteDocumentCommand(createCommand); _auditLogWFManager.AuditLogEntry("Inventory Transfer", string.Format("Created Inventory Transfer: {0}; From: {1}; To: {2}", document.Id, document.DocumentIssuerCostCentre.Name, document.DocumentRecipientCostCentre.Name)); var lineItemCommands = commandsToExecute.OfType<AfterCreateCommand>(); foreach (var _item in lineItemCommands) { var item = _item as AddInventoryTransferNoteLineItemCommand; envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, item)); // _commandRouter.RouteDocumentCommand(_item); _auditLogWFManager.AuditLogEntry("Inventory Transfer", string.Format("Transferred Product: {0}; Quantity: {1}; for Inventory Transfer: {2};", item.ProductId, item.Qty, document.Id)); } var co = commandsToExecute.OfType<ConfirmCommand>().First(); envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, co)); //_commandRouter.RouteDocumentCommand(co); _commandEnvelopeRouter.RouteCommandEnvelope(envelope); _auditLogWFManager.AuditLogEntry("Inventory Transfer", string.Format("Confirmed Inventory Transfer: {0}; From: {1}; To: {2}", document.Id, document.DocumentIssuerCostCentre.Name, document.DocumentRecipientCostCentre.Name)); }
public void SubmitChanges(InventoryAdjustmentNote document, BasicConfig config) { int sequence = 0; var envelope = new CommandEnvelope(); envelope.Initialize(document); envelope.OtherRecipientCostCentreList.Add(Guid.NewGuid()); List<DocumentCommand> commandsToExecute = document.GetDocumentCommandsToExecute(); var createCommand = commandsToExecute.OfType<CreateCommand>().First(); // _commandRouter.RouteDocumentCommand(createCommand); envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence,createCommand)); _auditLogWFManager.AuditLogEntry("Inventory Adjustment", string.Format("Created IAN document: {0};", document.Id)); var lineItemCommands = commandsToExecute.OfType<AfterCreateCommand>(); foreach (var _item in lineItemCommands) { var item = _item as AddInventoryAdjustmentNoteLineItemCommand; envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, item)); _auditLogWFManager.AuditLogEntry("Inventory Adjustment", string.Format("Adjusted Product: {1}; quantity from: {2}; to: {3}; for IAN document: {0};", document.Id, item.ProductId, item.Actual, item.Actual)); } var co = commandsToExecute.OfType<ConfirmCommand>().First(); envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, co)); _commandEnvelopeRouter.RouteCommandEnvelope(envelope); _auditLogWFManager.AuditLogEntry("Inventory Adjustment", string.Format("Confirmed IAN document: {0};", document.Id)); }
public void Submit(MainOrder order) { int sequence = 0; var envelope = new CommandEnvelope(); envelope.Initialize(order); List<DocumentCommand> commandsToExecute = order.GetSubOrderCommandsToExecute(); var createCommand = commandsToExecute.OfType<CreateCommand>().FirstOrDefault(); if (createCommand != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, createCommand)); var lineItemCommands = commandsToExecute.OfType<AfterCreateCommand>(); foreach (var _item in lineItemCommands) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, _item)); } var editlineItemCommands = commandsToExecute.OfType<ChangeMainOrderLineItemCommand>(); foreach (var _editeditem in editlineItemCommands) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, _editeditem)); } var removedLineitem = commandsToExecute.OfType<RemoveMainOrderLineItemCommand>(); foreach (var _removeditem in removedLineitem) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, _removeditem)); } var co = commandsToExecute.OfType<ConfirmCommand>().FirstOrDefault(); if (co != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, co)); var rco = commandsToExecute.OfType<RejectMainOrderCommand>().FirstOrDefault(); if (rco != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, rco)); var approvedlineItemCommands = order.GetSubOrderCommandsToExecute().OfType<ApproveOrderLineItemCommand>(); foreach (var _item in approvedlineItemCommands) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, _item)); } var aop = commandsToExecute.OfType<ApproveCommand>().FirstOrDefault(); if (aop != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, aop)); var closecommand = commandsToExecute.OfType<CloseOrderCommand>().FirstOrDefault(); if (closecommand != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, closecommand)); _commandEnvelopeRouter.RouteCommandEnvelope(envelope); }
public void SubmitChanges(Receipt document,BasicConfig config) { int sequence = 0; var envelope = new CommandEnvelope(); envelope.Initialize(document); List<DocumentCommand> commandsToExecute = document.GetDocumentCommandsToExecute(); CreateCommand createCommand; //= commandsToExecute.OfType<CreateCommand>().First(); if (TryGetCreateCommand(commandsToExecute, out createCommand)) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, createCommand)); // _commandRouter.RouteDocumentCommand(createCommand); _auditLogWFManager.AuditLogEntry("Receipt", string.Format("Created Receipt: {0}; for invoice: {1}", document.Id, document.InvoiceId)); } List<AfterCreateCommand> lineItemCommands; if (TryGetAfterCreateCommands(commandsToExecute, out lineItemCommands)) { foreach (var item in lineItemCommands) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, item)); // _commandRouter.RouteDocumentCommand(item); var _item = item as AddReceiptLineItemCommand; _auditLogWFManager.AuditLogEntry("Receipt", string.Format( "Added Product type: {0}; Quantity: {1}; for Invoice: {2};", _item.LineItemType, _item.Value, document.InvoiceId)); } } ConfirmCommand confirmCommand; if (TryGetConfirmCommand(commandsToExecute, out confirmCommand)) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, confirmCommand)); // _commandRouter.RouteDocumentCommand(confirmCommand); _auditLogWFManager.AuditLogEntry("Receipt", string.Format("Confirmed Receipt: {0}; for Invoice: {1}", document.Id, document.InvoiceId)); // _notifyService.SubmitRecieptNotification(document); } _commandEnvelopeRouter.RouteCommandEnvelope(envelope); document.CallClearCommands(); }
public void SubmitChanges(Domain.Transactional.DocumentEntities.Invoice document, BasicConfig config) { int sequence = 0; var envelope = new CommandEnvelope(); envelope.Initialize(document); List<DocumentCommand> commandsToExecute = document.GetDocumentCommandsToExecute(); CreateCommand createCommand; //= commandsToExecute.OfType<CreateCommand>().First(); if (TryGetCreateCommand(commandsToExecute, out createCommand)) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, createCommand)); //_commandRouter.RouteDocumentCommand(createCommand); _auditLogWFManager.AuditLogEntry("Invoice", string.Format("Created Invoice: {0}; for Order: {1}", document.Id, document.OrderId)); } List<AfterCreateCommand> lineItemCommands; if (TryGetAfterCreateCommands(commandsToExecute, out lineItemCommands)) { foreach (var item in lineItemCommands) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, item)); // _commandRouter.RouteDocumentCommand(item); var _item = item as AddInvoiceLineItemCommand; _auditLogWFManager.AuditLogEntry("Invoice", string.Format( "Added Product: {0}; Quantity: {1}; for Invoice: {2};", _item.ProductId, _item.Qty, document.Id)); } } ConfirmCommand confirmCommand; if (TryGetConfirmCommand(commandsToExecute, out confirmCommand)) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, confirmCommand)); // _commandRouter.RouteDocumentCommand(confirmCommand); //send notification // _notifyService.SubmitInvoiceNotification(document); _auditLogWFManager.AuditLogEntry("Invoice", string.Format("Confirmed Invoice: {0}; for Order: {1}", document.Id, document.OrderId)); } _commandEnvelopeRouter.RouteCommandEnvelope(envelope); document.CallClearCommands(); }
public void SubmitChanges(CommodityWarehouseStorageNote document) { int sequence = 0; var envelope = new CommandEnvelope(); envelope.Initialize(document); List<DocumentCommand> commandsToExecute = document.GetDocumentCommandsToExecute(); CreateCommand createCommand = commandsToExecute.OfType<CreateCommand>().FirstOrDefault(); if (createCommand != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, createCommand)); List<AfterCreateCommand> lineItemCommands = commandsToExecute.OfType<AfterCreateCommand>().ToList(); foreach (var item in lineItemCommands) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, item)); } List<AfterConfirmCommand> lineItemConfirmCommands = commandsToExecute.OfType<AfterConfirmCommand>().ToList(); foreach (var item in lineItemConfirmCommands) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, item)); } ConfirmCommodityWarehouseStorageCommand confirmCommodityWarehouseStorageCommand = commandsToExecute.OfType<ConfirmCommodityWarehouseStorageCommand>().FirstOrDefault(); if (confirmCommodityWarehouseStorageCommand != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, confirmCommodityWarehouseStorageCommand)); ApproveCommodityWarehouseStorageCommand approveCommand = commandsToExecute.OfType<ApproveCommodityWarehouseStorageCommand>().FirstOrDefault(); if (approveCommand != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, approveCommand)); StoreCommodityWarehouseStorageCommand storeCommand = commandsToExecute.OfType<StoreCommodityWarehouseStorageCommand>().FirstOrDefault(); if (storeCommand != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, storeCommand)); _commandEnvelopeRouter.RouteCommandEnvelope(envelope); }
public void SubmitChanges(DispatchNote document, BasicConfig config) { //document.Confirm(); int sequence = 0; var envelope = new CommandEnvelope(); envelope.Initialize(document); List<DocumentCommand> commandsToExecute = document.GetDocumentCommandsToExecute(); CreateCommand createCommand; if (TryGetCreateCommand(commandsToExecute, out createCommand)) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, createCommand)); // _commandRouter.RouteDocumentCommand(createCommand); _auditLogWFManager.AuditLogEntry("Dispatch Note", string.Format("Dispatch Note Document No: {0}; to: {1}; Created", document.Id, document.DocumentRecipientCostCentre.Name)); } List<AfterCreateCommand> lineItemCommands; if (TryGetAfterCreateCommands(commandsToExecute, out lineItemCommands)) { foreach (var item in lineItemCommands) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, item)); //_commandRouter.RouteDocumentCommand(item); var _item = item as AddDispatchNoteLineItemCommand; _auditLogWFManager.AuditLogEntry("Dispatch Note", string.Format("Added Product: {1}; Quantity: {2}; Value: {3}; to Dispatch Note document: {0}", document.Id, item.Description, _item.Qty, _item.Value)); } } ConfirmCommand confirmCommand; if (TryGetConfirmCommand(commandsToExecute, out confirmCommand)) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, confirmCommand)); //_commandRouter.RouteDocumentCommand(confirmCommand); _auditLogWFManager.AuditLogEntry("Dispatch Note", string.Format("Confirmed Dispatch Note document: {0}", document.Id)); // _notifyService.SubmitDispatch(document); } _commandEnvelopeRouter.RouteCommandEnvelope(envelope); document.CallClearCommands(); }
public void SubmitChanges(CommodityDeliveryNote document) { int sequence = 0; var envelope = new CommandEnvelope(); envelope.Initialize(document); List<DocumentCommand> commandsToExecute = document.GetDocumentCommandsToExecute(); CreateCommand createCommand = commandsToExecute.OfType<CreateCommand>().FirstOrDefault(); if (createCommand != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, createCommand)); // _commandRouter.RouteDocumentCommand(createCommand); List<AfterCreateCommand> lineItemCommands = commandsToExecute.OfType<AfterCreateCommand>().ToList(); foreach (var item in lineItemCommands) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, item)); //_commandRouter.RouteDocumentCommand(item); } List<WeighedCommodityDeliveryLineItemCommand> weighed = commandsToExecute.OfType<WeighedCommodityDeliveryLineItemCommand>().ToList(); foreach (var item in weighed) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, item)); // _commandRouter.RouteDocumentCommand(item); } ConfirmCommodityDeliveryCommand confirmCommodityDeliveryCommand = commandsToExecute.OfType<ConfirmCommodityDeliveryCommand>().FirstOrDefault(); if (confirmCommodityDeliveryCommand != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, confirmCommodityDeliveryCommand)); // _commandRouter.RouteDocumentCommand(confirmCommodityDeliveryCommand); ApproveDeliveryCommand receivedDeliveryCommand = commandsToExecute.OfType<ApproveDeliveryCommand>().FirstOrDefault(); if (receivedDeliveryCommand != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, receivedDeliveryCommand)); //_commandRouter.RouteDocumentCommand(receivedDeliveryCommand); _commandEnvelopeRouter.RouteCommandEnvelope(envelope); }
public void SubmitChanges(InventoryReceivedNote irn,BasicConfig config) { int sequence = 0; var envelope = new CommandEnvelope(); envelope.Initialize(irn); List<DocumentCommand> commandsToExecute = irn.GetDocumentCommandsToExecute(); var createCommand = commandsToExecute.OfType<CreateCommand>().First(); envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, createCommand)); _auditLogWFManager.AuditLogEntry("Receive Inventory", string.Format("Created Goods Received Note: {0}; for Purchase Orders: {1}", irn.Id, irn.OrderReferences)); var lineItemCommands = commandsToExecute.OfType<AfterCreateCommand>(); foreach (var li in lineItemCommands) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, li)); AddInventoryReceivedNoteLineItemCommand c = li as AddInventoryReceivedNoteLineItemCommand; _auditLogWFManager.AuditLogEntry("Receive Inventory", string.Format("Received Product: {0}; Quantity: {1}; for Goods Received Note: {2};", c.ProductId, c.Qty, irn.Id)); } var co = commandsToExecute.OfType<ConfirmCommand>().First(); envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, co)); _commandEnvelopeRouter.RouteCommandEnvelope(envelope); _auditLogWFManager.AuditLogEntry("Receive Inventory", string.Format("Confirmed Goods Received Note: {0}; for Purchase Orders: {1}", irn.Id, irn.OrderReferences)); }
public void Submit(MainOrder order) { int sequence = 0; var envelope = new CommandEnvelope(); envelope.GeneratedByCostCentreApplicationId = Guid.Empty; envelope.Initialize(order); List<DocumentCommand> commandsToExecute = order.GetSubOrderCommandsToExecute(); var createCommand = commandsToExecute.OfType<CreateCommand>().FirstOrDefault(); if (createCommand != null) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, createCommand)); //AddToMongoDB(createCommand); } var lineItemCommands = commandsToExecute.OfType<AfterCreateCommand>(); foreach (var _item in lineItemCommands) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, _item)); //AddToMongoDB(_item); //_busPublisher.WrapAndPublish(_item, (CommandType)Enum.Parse(typeof(CommandType), _item.CommandTypeRef)); } var editlineItemCommands = commandsToExecute.OfType<ChangeMainOrderLineItemCommand>(); foreach (var _editeditem in editlineItemCommands) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, _editeditem)); } var removedLineitem = commandsToExecute.OfType<RemoveMainOrderLineItemCommand>(); foreach (var _removeditem in removedLineitem) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, _removeditem)); } var co = commandsToExecute.OfType<ConfirmCommand>().FirstOrDefault(); if (co != null) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, co)); } var rco = commandsToExecute.OfType<RejectMainOrderCommand>().FirstOrDefault(); if (rco != null) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, rco)); } var approvedlineItemCommands = order.GetSubOrderCommandsToExecute().OfType<ApproveOrderLineItemCommand>(); foreach (var _item in approvedlineItemCommands) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, _item)); } var aop = commandsToExecute.OfType<ApproveCommand>().FirstOrDefault(); if (aop != null) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, aop)); } AddToMongoDB(envelope); }
public void Submit(MainOrder order,BasicConfig config) { int sequence = 0; var envelope = new CommandEnvelope(); envelope.Initialize(order); List<DocumentCommand> commandsToExecute = order.GetSubOrderCommandsToExecute(); var createCommand = commandsToExecute.OfType<CreateCommand>().FirstOrDefault(); if (createCommand != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, createCommand)); var lineItemCommands = commandsToExecute.OfType<AfterCreateCommand>(); foreach (var _item in lineItemCommands) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, _item)); // _commandRouter.RouteDocumentCommand(_item); } var editlineItemCommands = commandsToExecute.OfType<ChangeMainOrderLineItemCommand>(); foreach (var _editeditem in editlineItemCommands) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, _editeditem)); //_commandRouter.RouteDocumentCommand(_editeditem); } var removedLineitem = commandsToExecute.OfType<RemoveMainOrderLineItemCommand>(); foreach (var _removeditem in removedLineitem) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, _removeditem)); } var co = commandsToExecute.OfType<ConfirmCommand>().FirstOrDefault(); if (co != null) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, co)); //_commandRouter.RouteDocumentCommand(co); _notifyService.SubmitOrderSaleNotification(order); } var rco = commandsToExecute.OfType<RejectMainOrderCommand>().FirstOrDefault(); if (rco != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, rco)); //adjust inventory from distributor Guid invoiceId; var approvedlineItemCommands = order.GetSubOrderCommandsToExecute().OfType<ApproveOrderLineItemCommand>(); foreach (var _item in approvedlineItemCommands) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, _item)); } HandleApprovedCommand(order,config,out invoiceId); var aop = commandsToExecute.OfType<ApproveCommand>().FirstOrDefault(); if (aop != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, aop)); var closecommand = commandsToExecute.OfType<CloseOrderCommand>().FirstOrDefault(); if (closecommand != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, closecommand)); var orderpaymentInfoitem = order.GetSubOrderCommandsToExecute().OfType<AddOrderPaymentInfoCommand>(); foreach (var paymentInfo in orderpaymentInfoitem) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, paymentInfo)); } HandlePayments(order,invoiceId, config); _commandEnvelopeRouter.RouteCommandEnvelope(envelope); }