public void SubmitChanges(InventoryAdjustmentNote document, BasicConfig config)
        {
            int sequence = 0;
            var envelope = new CommandEnvelope();
            envelope.Initialize(document);
            envelope.OtherRecipientCostCentreList.Add(Guid.NewGuid());
            List<DocumentCommand> commandsToExecute = document.GetDocumentCommandsToExecute();
            
            var createCommand = commandsToExecute.OfType<CreateCommand>().First();
           // _commandRouter.RouteDocumentCommand(createCommand);
            envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence,createCommand));
            _auditLogWFManager.AuditLogEntry("Inventory Adjustment", string.Format("Created IAN document: {0};", document.Id));

            var lineItemCommands = commandsToExecute.OfType<AfterCreateCommand>();
            foreach (var _item in lineItemCommands)
            {
                var item = _item as AddInventoryAdjustmentNoteLineItemCommand;
                envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, item));
             
                _auditLogWFManager.AuditLogEntry("Inventory Adjustment", string.Format("Adjusted Product: {1}; quantity from: {2}; to: {3}; for IAN document: {0};", document.Id, item.ProductId, item.Actual, item.Actual));
            }
            
            var co = commandsToExecute.OfType<ConfirmCommand>().First();
            envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, co));
            _commandEnvelopeRouter.RouteCommandEnvelope(envelope);
            _auditLogWFManager.AuditLogEntry("Inventory Adjustment", string.Format("Confirmed IAN document: {0};", document.Id));
        }
 public void Submit(InventoryAdjustmentNote note)
 {
     int sequence = 0;
     var envelope = new CommandEnvelope();
     envelope.Initialize(note);
     List<DocumentCommand> commandsToExecute = note.GetDocumentCommandsToExecute();
     var createCommand = commandsToExecute.OfType<CreateCommand>().First();
    
     if (createCommand != null)
     {
         envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, createCommand));
     }
     var lineItemCommands = commandsToExecute.OfType<AfterCreateCommand>();
     foreach (var _item in lineItemCommands)
     {
         envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, _item));
     }
     var co = commandsToExecute.OfType<ConfirmCommand>().First();
     if (co != null)
     {
         envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, co));
     }
     
     AddToMongoDB(envelope);
 }
Пример #3
0
        private void SaveIAN()
        {
            
            using (StructureMap.IContainer c = NestedContainer)
            {
                User user = Using<IUserRepository>(c).GetById(Using<IConfigService>(c).ViewModelParameters.CurrentUserId);

                CostCentre cc = Using<ICostCentreRepository>(c) .GetById(Using<IConfigService>(c).Load().CostCentreId);
                Guid ccAppId = Using<IConfigService>(c).Load().CostCentreApplicationId;
                InventoryAdjustmentNoteType t = AdjustInventory
                                                       ? InventoryAdjustmentNoteType.AdjustOnly
                                                       : InventoryAdjustmentNoteType.StockTake;
                note = Using<IInventoryAdjustmentNoteFactory>(c).Create(cc, ccAppId, cc, user, "", t, Guid.Empty);


                var itemsToAdd = LineItems.Select(n => Using<IInventoryAdjustmentNoteFactory>(c)
                                                           .CreateLineItem(n.ActualQty, n.Id, n.ExpectedQty, 0, n.Reason))
                                          .ToList();
                foreach (var i in itemsToAdd) { 
                    note.AddLineItem(i);
                }

                

               // note._SetLineItems(itemsToAdd);
              //Using<IMessageBoxWrapper>(c).Show("Successfully Saved", "Information", MessageBoxButton.OK);
            }
        }
Пример #4
0
 public void SubmitToWF(InventoryAdjustmentNote ian)
 {
     _inventoryAdjustmentNoteWfManager.SubmitChanges(ian, null);
 }