public void Execute(IDocumentSession session, IEventStoreSession eventStoreSession) { var matchResult = new MatchResult4( roster, result.TeamScore, result.OpponentScore, roster.BitsMatchId); var series = new[] { result.Series.ElementAtOrDefault(0), result.Series.ElementAtOrDefault(1), result.Series.ElementAtOrDefault(2), result.Series.ElementAtOrDefault(3) }; foreach (var serie in series.Where(x => x != null)) { var games = new List<MatchGame4>(); for (var i = 0; i < 4; i++) { var game = serie.Games[i]; var matchGame = new MatchGame4(game.Player, game.Score, game.Pins); games.Add(matchGame); } matchResult.RegisterSerie(new MatchSerie4(games)); } eventStoreSession.Store(matchResult); }
protected override void OnActionExecuting(ActionExecutingContext filterContext) { DocumentStore = MvcApplication.Container.Resolve<IDocumentStore>(); DocumentSession = MvcApplication.Container.Resolve<IDocumentSession>(); EventStoreSession = MvcApplication.Container.Resolve<IEventStoreSession>(); EventStore = MvcApplication.Container.Resolve<EventStore>(); }
public static User Register(IEventStoreSession aggregates, string email, string password, Guid id) { var user = new User(); user.Register(email, password, id); aggregates.Save(user); return(user); }
public static MyAccount Register(IEventStoreSession aggregates, Guid accountId, string email, string password) { var registered = new MyAccount(); registered.RaiseEvent(new AccountRegisteredEvent(accountId, email, password)); aggregates.Save(registered); return(registered); }
public static async Task <(CustomerAggregate root, bool ok)> LoadAsync( this IEventStoreSession sess, string streamId, IAggregateRootServices services) { var aggregate = new CustomerAggregate(streamId, services); var success = await sess.HydrateAsync <CustomerAggregate, Customer>(aggregate).ConfigureAwait(false); return(success ? (aggregate, true) : (null, false)); }
private static void CreateDomainObject(IEventStoreSession session) { var existingCustomer = session.Load<Customer>("EventStreams/Customers/5"); if (existingCustomer != null) existingCustomer.PrintName(Console.Out); else { var customer = new Customer("Daniel Lidström"); customer.ChangeName("Per Daniel Lidström"); session.Store(customer); } }
public EventStoreEventStore(IEventStoreSession eventStoreConnection, ILogger logger) { if (eventStoreConnection == null) { throw new ArgumentNullException("eventStoreConnection"); } if (logger == null) { throw new ArgumentNullException("logger"); } _eventStoreConnection = eventStoreConnection; _logger = logger; }
private static void CreateDomainObject(IEventStoreSession session) { /*var existingCustomer = session.Load<Customer>("EventStreams/Customers/1"); if (existingCustomer != null) existingCustomer.PrintName(Console.Out); else*/ { var n = random.Next(10); for (int i = 0; i < n; i++) { var customer = new Customer("Daniel Lidström" + random.Next(5)); customer.ChangeName("Per Daniel Lidström" + random.Next(20, 40)); session.Store(customer); if (random.Next(3) > 1) session.SaveChanges(); } } }
public void SetUp() { _logger = new ConsoleLogger(); _eventStoreConnection = EventStoreConnection.Create(new IPEndPoint(IPAddress.Loopback, 1113)); _eventStoreConnection.ConnectAsync().Wait(); _eventStoreSession = new EventStoreSession(_eventStoreConnection, _logger); Resolver.Configure( type => { if (type == typeof(ILogger)) { return(_logger); } throw new InvalidOperationException($"No type of {type} registered."); }, type => null, o => { }); }
public void Execute(IDocumentSession session, IEventStoreSession eventStoreSession) { var matchResult = new MatchResult( roster, result.TeamScore, result.OpponentScore, roster.BitsMatchId); var series = new[] { result.Series.ElementAtOrDefault(0), result.Series.ElementAtOrDefault(1), result.Series.ElementAtOrDefault(2), result.Series.ElementAtOrDefault(3) }; var matchSeries = new List<MatchSerie>(); foreach (var serie in series.Where(x => x != null)) { var tables = new List<MatchTable>(); for (var i = 0; i < 4; i++) { var game1 = new MatchGame( serie.Tables[i].Game1.Player, serie.Tables[i].Game1.Pins, serie.Tables[i].Game1.Strikes, serie.Tables[i].Game1.Spares); var game2 = new MatchGame( serie.Tables[i].Game2.Player, serie.Tables[i].Game2.Pins, serie.Tables[i].Game2.Strikes, serie.Tables[i].Game2.Spares); tables.Add(new MatchTable(game1, game2, serie.Tables[i].Score)); } matchSeries.Add(new MatchSerie(tables)); } matchResult.RegisterSeries(matchSeries); eventStoreSession.Store(matchResult); }
public void ThrowsIfUsedByMultipleThreads() { var store = CreateStore(); IEventStoreSession session = null; var wait = new ManualResetEventSlim(); ThreadPool.QueueUserWorkItem((state) => { session = OpenSession(store); wait.Set(); }); wait.Wait(); User user; Assert.Throws <MultiThreadedUseException>(() => session.Get <User>(Guid.NewGuid())); Assert.Throws <MultiThreadedUseException>(() => session.Dispose()); Assert.Throws <MultiThreadedUseException>(() => session.LoadSpecificVersion <User>(Guid.NewGuid(), 1)); Assert.Throws <MultiThreadedUseException>(() => session.Save(new User())); Assert.Throws <MultiThreadedUseException>(() => session.SaveChanges()); Assert.Throws <MultiThreadedUseException>(() => session.TryGet(Guid.NewGuid(), out user)); }
public void Dispose() { _session.Dispose(); _session = null; }
public RavenDbStoreRepository(IEventStoreSession session) { _session = session; }
public AggregateRepository(IEventStoreSession aggregates) { Aggregates = aggregates; }
public static async Task <bool> HydrateAsync(this IEventStoreSession sess, CustomerAggregate aggregate) { return(await sess.HydrateAsync <CustomerAggregate, Customer>(aggregate).ConfigureAwait(false)); }
public static async Task <bool> SaveUncommitedEventsAsync(this IEventStoreSession sess, CustomerAggregate aggregate) { return(await sess.SaveUncommitedEventsAsync <CustomerAggregate, Customer>(aggregate).ConfigureAwait(false)); }