Example #1
0
        public async Task <Reservation> CreateAsync(EntityId id, CinemaId cinemaId, MovieId movieId, HallId hallId, CustomerId customerId,
                                                    DateTime dateTime, bool isPaymentUponArrival, IEnumerable <Seat> seats, Reservee reservee)
        {
            var areSeatsValid = await _validator.ValidateAsync(cinemaId, movieId, hallId, seats);

            if (!areSeatsValid)
            {
                throw new SeatsAlreadyReservedException(id);
            }

            if (!customerId.IsEmpty())
            {
                reservee = await _provider.GetAsync(customerId);
            }

            var status      = isPaymentUponArrival ? ReservationStatus.PaymentUponArrival : ReservationStatus.Pending;
            var reservation = Reservation.Create(id, cinemaId, movieId, hallId, dateTime, status, reservee, seats);

            return(reservation);
        }