public async Task Save(TAggregate aggregate, bool takeSnapshot = false) { await _eventStore.Append(aggregate.GetId(), aggregate.Version, GetPendingEvents(aggregate)); aggregate.ClearPendingEvents(); if (takeSnapshot) { var snapshot = _snapshotFactory.Create <TAggregate, TState>(aggregate); await _snapShotStore.TakeSnapshot(snapshot); } }