コード例 #1
0
 private void AddItemToList(CommodityDeliveryNote sourcingDocument)
 {
     var item = new CommodityDeliveryListItem();
     item.DocumentId = sourcingDocument.Id;
     item.DocumentReference = sourcingDocument.DocumentReference;
     item.Description = sourcingDocument.Description;
     item.DateIssued = sourcingDocument.DocumentDateIssued;
     item.ClerkName = sourcingDocument.DocumentIssuerUser.Username;
     item.NoOfContainers = sourcingDocument.LineItems.GroupBy(s => s.ContainerNo).Count();
     item.Status = sourcingDocument.Status;
     item.DriverName = sourcingDocument.DriverName;
     item.VehicleRegNo = sourcingDocument.VehiclRegNo;
     item.NetWeight = TruncateDecimal(sourcingDocument.LineItems.Sum(s => s.Weight), 1);
     item.TareWeight = TruncateDecimal(sourcingDocument.LineItems.Sum(k => k.ContainerType.TareWeight), 1);
     item.GrossWeight = item.NetWeight + item.TareWeight;
     LineItem.Add(item);
 }
コード例 #2
0
        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);
        }