Ejemplo n.º 1
0
        public void DoWork()
        {
            var guid = Guid.Parse("f63469c1-9caa-4a17-b7f5-3c8248193de9");

            using (var store = new DocumentStore
            {
                Urls = new[] { "http://localhost:8888" },
                Database = "BankAccountEventStore"
            })
            {
                store.Initialize();
                using (var session = store.OpenSession())
                {
                    IEventStore eventStore  = new RavenDbEventStore(session);
                    var         repository  = new BankAccountRepository(eventStore);
                    var         bankAccount = repository.FindBy(guid);

                    repository.SaveSnapshot(bankAccount.Snapshot(), bankAccount);

                    bankAccount.Deposit(new Money(200m));
                    repository.Save(bankAccount);


                    session.SaveChanges();


//                    repository.SaveSnapshot(bankAccount.Snapshot(), bankAccount);
//                    session.SaveChanges();
//
//                    var bankAccountOption = repository.FindBy(guid);
//                    var bankAccount2 = bankAccountOption.Value;
                }
            }
        }