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);
            }
        }
예제 #2
0
 public UserAggregate(UserState state)
 {
     _state = state;
 }