public void SubmitChanges(ReceivedDeliveryNote 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<ApproveCommand> stored = commandsToExecute.OfType<ApproveCommand>().ToList(); foreach (var item in stored) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, item)); // _commandRouter.RouteDocumentCommand(item); } ConfirmReceivedDeliveryCommand confirmReceivedDeliveryCommand = commandsToExecute.OfType<ConfirmReceivedDeliveryCommand>().FirstOrDefault(); if (confirmReceivedDeliveryCommand != null) //_commandRouter.RouteDocumentCommand(confirmReceivedDeliveryCommand); envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, confirmReceivedDeliveryCommand)); _commandEnvelopeRouter.RouteCommandEnvelope(envelope); }
private CommodityReceptionListItem Map(ReceivedDeliveryNote doc) { var item = new CommodityReceptionListItem { DocumentId = doc.Id, DocumentReference = doc.DocumentReference, DateIssued = doc.DocumentDateIssued, ClerkName = doc.DocumentIssuerUser.Username, Description = doc.Description, NetWeight =TruncateDecimal(doc.TotalNetWeight,1), NoOfContainers = doc.LineItems.Count, Status = doc.Status }; return item; }