private Reservation( Guid id, IReservationNumberGenerator numberGenerator, Guid seatId) { if (id == Guid.Empty) { throw new ArgumentOutOfRangeException(nameof(id)); } if (seatId == Guid.Empty) { throw new ArgumentOutOfRangeException(nameof(seatId)); } var reservationNumber = numberGenerator.Next(); var @event = TentativeReservationCreated.Create( id, seatId, reservationNumber ); Enqueue(@event); Apply(@event); }
public void Apply(TentativeReservationCreated @event) { Id = @event.ReservationId; SeatId = @event.SeatId; Number = @event.Number; Status = ReservationStatus.Tentative; Version++; }
private Reservation( ReservationId id, SeatId seatId, CustomerId customerId, ReservationNumber reservationNumber ) { var @event = new TentativeReservationCreated( id, seatId, customerId, reservationNumber ); Enqueue(@event); Apply(@event); }
private Reservation( Guid id, IReservationNumberGenerator numberGenerator, Guid seatId) { Guard.Against.Null(id, nameof(id)); Guard.Against.Null(numberGenerator, nameof(numberGenerator)); Guard.Against.Default(seatId, nameof(seatId)); var reservationNumber = numberGenerator.Next(); var @event = TentativeReservationCreated.Create( id, seatId, reservationNumber ); Enqueue(@event); Apply(@event); }