public void Execute(CreateInventoryTransferNoteCommand command) { _log.InfoFormat("Execute {1} - Command Id {0} ", command.CommandId, command.GetType().ToString()); try { if( DocumentExists(command.DocumentId)) return; tblDocument doc = NewDocument(command, DocumentType.InventoryTransferNote, command.DocumentRecipientCostCentreId); doc.OrderIssuedOnBehalfOfCC = command.IssuedOnBehalfOfCostCentreId; _cokeDataContext.tblDocument.AddObject(doc); _cokeDataContext.SaveChanges(); } catch (Exception ex) { _log.ErrorFormat("Error Execute {1} - Command Id {0} ", command.CommandId, command.GetType().ToString()); _log.Error("CreateInventoryTransferNoteCommandHandler exception", ex); throw ; } }
//IAN //List<CommandRouteItem> GetCreateInventoryAdjustmentNoteCommandRoutes(CreateInventoryAdjustmentNoteCommand createInventoryAdjustmentNoteCommand) //{ // List<CommandRouteItem> commandRouteItems = new List<CommandRouteItem>(); // string serializedCommand = JsonConvert.SerializeObject(createInventoryAdjustmentNoteCommand); // List<int> destinationIds = GetDestinationApplicationIdsForCostCentres(createInventoryAdjustmentNoteCommand.DocumentIssuerCostCentreId, createInventoryAdjustmentNoteCommand.DocumentIssuerCostCentreId); // int[] _destinationIds = RemoveSourceCCAppId(destinationIds.ToArray(), createInventoryAdjustmentNoteCommand); // foreach (int appId in _destinationIds) // commandRouteItems.Add(CreateRouteItem(createInventoryAdjustmentNoteCommand, "CreateInventoryAdjustmentNote", appId, serializedCommand)); // return commandRouteItems; //} //private List<int> GetDestinationIdsFromInventoryAdjustmentNoteId(Guid IANId) //{ // InventoryAdjustmentNote ian = _inventoryAdjustmentNoteRepository.GetById(IANId) as InventoryAdjustmentNote; // return GetDestinationApplicationIdsForCostCentres(ian.DocumentIssuerCostCentre.Id, ian.DocumentRecipientCostCentre.Id); //} //List<CommandRouteItem> GetAddInventoryAdjustmentNoteLineItemCommandRoutes(AddInventoryAdjustmentNoteLineItemCommand addInventoryAdjustmentNoteLineItemCommand) //{ // List<CommandRouteItem> commandRouteItems = new List<CommandRouteItem>(); // string serializedCommand = JsonConvert.SerializeObject(addInventoryAdjustmentNoteLineItemCommand); // List<int> ids = GetDestinationIdsFromInventoryAdjustmentNoteId(addInventoryAdjustmentNoteLineItemCommand.DocumentId); // int[] _destinationIds = RemoveSourceCCAppId(ids.ToArray(), addInventoryAdjustmentNoteLineItemCommand); // foreach (int id in _destinationIds) // commandRouteItems.Add(CreateRouteItem(addInventoryAdjustmentNoteLineItemCommand, "AddInventoryAdjustmentNoteLineItem", id, serializedCommand)); // return commandRouteItems; //} //List<CommandRouteItem> GetConfirmInventoryAdjustmentNoteCommandRoutes(ConfirmInventoryAdjustmentNoteCommand confirmInventoryAdjustmentNoteCommand) //{ // List<CommandRouteItem> commandRouteItems = new List<CommandRouteItem>(); // string serializedCommand = JsonConvert.SerializeObject(confirmInventoryAdjustmentNoteCommand); // List<int> ids = GetDestinationIdsFromInventoryAdjustmentNoteId(confirmInventoryAdjustmentNoteCommand.DocumentId); // int[] _destinationIds = RemoveSourceCCAppId(ids.ToArray(), confirmInventoryAdjustmentNoteCommand); // foreach (int id in _destinationIds) // commandRouteItems.Add(CreateRouteItem(confirmInventoryAdjustmentNoteCommand, "ConfirmInventoryAdjustmentNote", id, serializedCommand)); // return commandRouteItems; //} //ITN List<CommandRouteItem> GetCreateInventoryTransferNoteCommandRoutes(CreateInventoryTransferNoteCommand createInventoryTransferNoteCommand) { List<CommandRouteItem> commandRouteItems = new List<CommandRouteItem>(); string serializedCommand = JsonConvert.SerializeObject(createInventoryTransferNoteCommand); List<Guid> destinationIds = GetDestinationApplicationIdsForCostCentres(createInventoryTransferNoteCommand.DocumentIssuerCostCentreId, createInventoryTransferNoteCommand.DocumentIssuerCostCentreId); Guid[] _destinationIds = RemoveSourceCCAppId(destinationIds.ToArray(), createInventoryTransferNoteCommand); foreach (Guid appId in _destinationIds) commandRouteItems.Add(CreateRouteItem(createInventoryTransferNoteCommand, "CreateInventoryTransferNote", appId, serializedCommand)); return commandRouteItems; }