Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
 public void Apply(Day day, TripStarted e) => day.Started++;
Ejemplo n.º 3
0
 // Create a new aggregate based on the initial
 // event type
 internal Trip(TripStarted started)
 {
     StartedOn = started.Day;
     Active    = true;
 }