public void Handle(ReserveSeats command)
        {
            var state     = new ScreeningState(_eventStore.EventsFor(command.ScreeningId));
            var screening = new Screening(state, PublishWith(state));

            screening.Reserve(command.CustomerId, command.Seats);
        }
 protected override void When(object evt)
 {
     State = evt switch
     {
         V1.ScreeningScheduled e => State.With(x =>
         {
             x.Id       = e.ScreeningId;
             x.Capacity = e.TheaterCapacity;
         }),
         V1.SeatReserved e => State.When(e),
         _ => State
     };
 }
 Action <Event> PublishWith(ScreeningState state) => (Event @event) =>
 {
     state.Apply(@event);
     _publish(@event);
 };
Example #4
0
 public Screening(IEnumerable <IEvent> history, Action <IEvent> publish)
 {
     _state   = new ScreeningState(history);
     _publish = publish;
 }
 public void GivenTheScreening(string movie, DateTime timeOfDay, string room, string cinema)
 {
     _events.Add(new ScreeningPlanned(movie, timeOfDay, room, cinema));
     _screening = new ScreeningState(_events);
 }