public async Task SaveAsync <TAggregate>(IAggregateRoot <TAggregate> aggregateRoot, string stream) { await _connection.AppendToStreamAsync(stream, aggregateRoot.OriginalVersion, aggregateRoot.GetUncommittedEvents()); aggregateRoot.ClearUncommittedEvents(); }
private EventStream CreateEventStream(IAggregateRoot aggregateRoot, ICommand command) { var uncommittedEvents = aggregateRoot.GetUncommittedEvents().ToList(); aggregateRoot.ClearUncommittedEvents(); var aggregateRootTypeCode = _aggregateRootTypeProvider.GetTypeCode(aggregateRoot.GetType()); foreach (var evnt in uncommittedEvents) { evnt.Version = aggregateRoot.Version + 1; } return new EventStream( command.Id, aggregateRoot.UniqueId, aggregateRootTypeCode, aggregateRoot.Version + 1, DateTime.Now, uncommittedEvents); }