void Update(ICommand<UserId> c, Action<UserAggregate> action)
        {
            var stream = _store.LoadEventStream(c.Id);
            var state = new UserState(stream.Events);
            var agg = new UserAggregate(state);

            using (Context.CaptureForThread()) {
                agg.ThrowOnInvalidStateTransition(c);
                action(agg);
                _store.AppendEventsToStream(c.Id, stream.StreamVersion, agg.Changes);
            }
        }
Exemple #2
0
        void Update(ICommand <UserId> c, Action <UserAggregate> action)
        {
            var stream = _store.LoadEventStream(c.Id);
            var state  = new UserState(stream.Events);
            var agg    = new UserAggregate(state);

            using (Context.CaptureForThread()) {
                agg.ThrowOnInvalidStateTransition(c);
                action(agg);
                _store.AppendToStream(c.Id, stream.Version, agg.Changes);
            }
        }