public async Task Handle(CreateNewTrip trip) { var started = new TripStarted { Day = trip.Day }; var departure = new Departure { Day = trip.Day, State = trip.State }; var travel = new Travel { Day = trip.Day, Movements = new List <Movement>(trip.Movements) }; // This will create a new event stream and // append the three events to that new stream // when the IDocumentSession is saved var action = _session.Events .StartStream(started, departure, travel); // You can also use strings as the identifier // for streams var tripId = action.Id; // Commit the events to the new event // stream for this trip await _session.SaveChangesAsync(); }
public void Apply(Day day, TripStarted e) => day.Started++;
// Create a new aggregate based on the initial // event type internal Trip(TripStarted started) { StartedOn = started.Day; Active = true; }