コード例 #1
0
    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);
    }
コード例 #2
0
 public void Apply(TentativeReservationCreated @event)
 {
     Id     = @event.ReservationId;
     SeatId = @event.SeatId;
     Number = @event.Number;
     Status = ReservationStatus.Tentative;
     Version++;
 }
コード例 #3
0
    private Reservation(
        ReservationId id,
        SeatId seatId,
        CustomerId customerId,
        ReservationNumber reservationNumber
        )
    {
        var @event = new TentativeReservationCreated(
            id,
            seatId,
            customerId,
            reservationNumber
            );

        Enqueue(@event);
        Apply(@event);
    }
コード例 #4
0
        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);
        }