public void Execute(CreateOutletVisitNoteCommand command)
        {
            _log.InfoFormat("Execute {1} - Command Id {0} ", command.CommandId, command.GetType().ToString());
            try
            {
                if (DocumentExists(command.DocumentId))
                    return;

                tblDocument doc = NewDocument(command, DocumentType.OutletVisitNote, command.DocumentRecipientCostCentreId);
                doc.Note = command.Description;
                doc.OrderIssuedOnBehalfOfCC = command.DocumentOnBehalfCostCentreId;
                doc.PaymentDocId = command.ReasonId;
                _cokeDataContext.tblDocument.AddObject(doc);
                _cokeDataContext.SaveChanges();

            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Error Execute {1} - Command Id {0} ", command.CommandId, command.GetType().ToString());
                _log.Error("CreateReceiptCommandHandler exception ", ex);
                throw;
            }
        }
示例#2
0
 private static void TestOutLetVisitCommand()
 {
     CreateOutletVisitNoteCommand cmd = new CreateOutletVisitNoteCommand();
     var route = ObjectFactory.GetInstance<IOutgoingDocumentCommandRouter>();
     var costCentreRepository = ObjectFactory.GetInstance<ICostCentreRepository>();
     var config = ObjectFactory.GetInstance<IConfigService>().Load();
     cmd.CommandGeneratedByCostCentreApplicationId = config.CostCentreApplicationId;
     cmd.CommandId = Guid.NewGuid();
     cmd.DocumentId = Guid.NewGuid();
     cmd.DocumentRecipientCostCentreId = costCentreRepository.GetAll().OfType<Distributor>().First().Id;
     cmd.DocumentOnBehalfCostCentreId = costCentreRepository.GetAll().OfType<Outlet>().First().Id;
     cmd.DocumentIssuerCostCentreId = config.CostCentreId;
     cmd.DocumentDateIssued = DateTime.Now;
     cmd.Note = "TEST";
     cmd.ReasonId = ObjectFactory.GetInstance<IOutletVisitReasonsTypeRepository>().GetAll().First().Id;
     route.RouteDocumentCommand(cmd);
 }