public void Execute(ConfirmInventoryTransferNoteCommand command) { _log.InfoFormat("Execute {1} - Command Id {0} ", command.CommandId, command.GetType().ToString()); try { if(!DocumentExists(command.DocumentId)) return; ConfirmDocument(command.DocumentId); InventoryTransferNote inventoryTransferNote = _documentRepository.GetById(command.DocumentId) ; foreach (var item in inventoryTransferNote.LineItems) { //adjust the stock Distributor _inventoryWorkflow.InventoryAdjust(inventoryTransferNote.DocumentIssuerCostCentre.Id, item.Product.Id, -(item.Qty), DocumentType.InventoryTransferNote , inventoryTransferNote.Id, inventoryTransferNote.DocumentDateIssued, InventoryAdjustmentNoteType.Available); //adjust the stock Sales Man _inventoryWorkflow.InventoryAdjust(inventoryTransferNote.DocumentRecipientCostCentre.Id, item.Product.Id, item.Qty, DocumentType.InventoryTransferNote , inventoryTransferNote.Id, inventoryTransferNote.DocumentDateIssued, InventoryAdjustmentNoteType.Available); } } catch (Exception ex) { _log.ErrorFormat("Error Execute {1} - Command Id {0} ", command.CommandId, command.GetType().ToString()); _log.Error ("ConfirmInventoryTransferNoteCommandHandler exception", ex); throw ; } }
List<CommandRouteItem> GetConfirmInventoryTransferNoteCommandRoutes(ConfirmInventoryTransferNoteCommand confirmInventoryTransferNoteCommand) { List<CommandRouteItem> commandRouteItems = new List<CommandRouteItem>(); string serializedCommand = JsonConvert.SerializeObject(confirmInventoryTransferNoteCommand); List<Guid> ids = GetDestinationIdsFromInventoryTransferNoteId(confirmInventoryTransferNoteCommand.DocumentId); Guid[] _destinationIds = RemoveSourceCCAppId(ids.ToArray(), confirmInventoryTransferNoteCommand); foreach (Guid id in _destinationIds) commandRouteItems.Add(CreateRouteItem(confirmInventoryTransferNoteCommand, "ConfirmInventoryTransferNote", id, serializedCommand)); return commandRouteItems; }