public async Task SaveAsync(IAggregateRoot aggregate) { IList <IEvent> events = aggregate.FlushPendingEvents().ToList(); await _eventStore.Save(aggregate.Id, events, aggregate.Version); foreach (IEvent e in events) { await _mediator.Publish(e); } }