Ejemplo n.º 1
0
        public SeatsReserved ReserveSeats(ReserveSeats reserveSeats)
        {
            var rows = new List <Row>();
            Row rowWithAvailableSeats = null;

            foreach (var row in _rows)
            {
                if (!(rowWithAvailableSeats is null) || !row.HasAvailableSeats(reserveSeats.SeatsToBeReserved))
                {
                    rows.Add(Row.CreateFromRow(row));
                    continue;
                }

                rowWithAvailableSeats = row;
            }

            if (rowWithAvailableSeats is null)
            {
                throw new SeatsNotAvailable();
            }

            rows.Add(rowWithAvailableSeats.ReserveSeats(reserveSeats.SeatsToBeReserved));

            _rows = rows.OrderBy(x => x.RowNumber).ToList();

            return(new SeatsReserved(reserveSeats.SeatsToBeReserved));
        }
        public SeatsReserved ReserveSeats(ReserveSeats reserveSeats)
        {
            if (reserveSeats.SeatsToBeReserved > 8)
            {
                throw new MaximumEightSeatsPerCustomer();
            }

            var movieScreening = _movieScreeningRepository.FindMovieScreening(reserveSeats.MovieScreeningId);

            return(movieScreening.ReserveSeats(reserveSeats));
        }
Ejemplo n.º 3
0
 public void Handle(ReserveSeats command)
 {
     Screening.Reserve(command.Customer, command.SeatsToReserve);
 }