public async Task<IEnumerable<Seat>> GetFreeSeatsAsync(Schedule schedule) { ValidateNotNull(schedule); await ValidateId(_scheduleDao, schedule.Id); var reservations = await _reservationDao.SelectReservationsByScheduleId(schedule.Id); if (!reservations.Any()) { return await _seatDao.SelectActiveWithRowAndCategoryByCinemaHallAsync(schedule.CinemaHallId); } var occupiedSeats = await _seatReservationDao.SelectAllSeatIdsByReservationIdsAsync(reservations.Select(reservation => reservation.Id)); return await _seatDao.SelectFreeSeatsByIdAsync(occupiedSeats); }
public async Task <IEnumerable <Seat> > GetActiveSeatsWithRowAndCategoryAsync(long cinemaHallId) { await ValidateId(_cinemaHallDao, cinemaHallId); return(await _seatDao.SelectActiveWithRowAndCategoryByCinemaHallAsync(cinemaHallId)); }