public void AddViewingAndSeatCreationEvents(ViewingId viewingId, int capacity) { var viewingCreatedEvent = new ViewingCreatedEvent(viewingId, capacity); using (var session = ViewingFunctionalRepo.BeginSessionFor(viewingCreatedEvent.ViewingId).Result) { session.AddEvent(viewingCreatedEvent); session.SaveChanges().Wait(); } for (ushort i = 0; i < capacity; i++) { AddSeatCreatedEvent(viewingCreatedEvent.ViewingId, i); } }
public IViewingState Apply(IViewingState state, ViewingCreatedEvent envelope) { //Use Automapper here?? state.ViewingId = envelope.ViewingId; state.Seats = new Seats[envelope.Seats]; for (int i = 0; i < state.Seats.Length; i++) { state.Seats[i] = new Seats { Id = i, IsReserved = false } } ; return(state); }