public void Execute(AddInventoryTransferNoteLineItemCommand command)
        {
             _log.InfoFormat("Execute {1} - Command Id {0} ", command.CommandId, command.GetType());
             try
             {
                 if (!DocumentExists(command.DocumentId))
                 {
                     _log.InfoFormat("Cannot add line item. Document does not exist. Execute {1} - Command Id {0} ", command.CommandId, command.GetType());
                     return;
                 }

                 if (DocumentLineItemExists(command.CommandId))
                 {
                     _log.InfoFormat("Cannot add line item. Line item already exists. Execute {1} - Command Id {0} ", command.CommandId, command.GetType());
                     return;
                 }

                 tblDocument document = ExistingDocument(command.DocumentId);
                 tblLineItems lineItem = NewLineItem(command.CommandId, command.DocumentId, command.ProductId,
                                                     command.Description, command.Qty, command.LineItemSequenceNo);
                 document.tblLineItems.Add(lineItem);
                 _cokeDataContext.SaveChanges();
             }
             catch (Exception ex)
             {
                 _log.ErrorFormat("Error Execute {1} - Command Id {0} ", command.CommandId, command.GetType().ToString());
                _log.Error("AddInventoryTransferNoteLineItemCommandHandler exception", ex);
                 throw ;
             }
        }
コード例 #2
0
        List<CommandRouteItem> GetAddInventoryTransferNoteLineItemCommandRoutes(AddInventoryTransferNoteLineItemCommand addInventoryTransferNoteLineItemCommand)
        {
            List<CommandRouteItem> commandRouteItems = new List<CommandRouteItem>();
            string serializedCommand = JsonConvert.SerializeObject(addInventoryTransferNoteLineItemCommand);

            List<Guid> ids = GetDestinationIdsFromInventoryTransferNoteId(addInventoryTransferNoteLineItemCommand.DocumentId);

            Guid[] _destinationIds = RemoveSourceCCAppId(ids.ToArray(), addInventoryTransferNoteLineItemCommand);

            foreach (Guid id in _destinationIds)
                commandRouteItems.Add(CreateRouteItem(addInventoryTransferNoteLineItemCommand, "AddInventoryTransferNoteLineItem", id, serializedCommand));
            return commandRouteItems;
        }
コード例 #3
0
 public void Handle(AddInventoryTransferNoteLineItemCommand command)
 {
     // Only adjust inventory when it is a standalone inventory adjustment that is not
     // the result of a dispatched order. Order's manage their own inventory and use the approved
     // quantity as their inventory. The inventory adjusted here is what is available for point-of-sale stuff. 
     if (command.PDCommandId == currentParentGuid.GetValueOrDefault())
     {
         inventoryRepository.AdjustInventoryForProduct(command.ProductId, command.Qty);
     }            
 }