Пример #1
0
        public async Task CommitAsync()
        {
            foreach (var aggregate in this.stagedAggregates)
            {
                // Persists aggregate state
                await aggregatesRepository.CommitChangesAsync(aggregate);

                // Sets applies all staged events to aggregate state
                aggregate.Commit();
            }

            // On purpose I am not clearing staged aggregates collection untill all of them are commited
            // (Rollback might be triggered in case of error)
            this.stagedAggregates.Clear();
        }