コード例 #1
0
        private async Task <Room> FindAvailableRoom(ReservationDTO res)
        {
            var reservationsInProgress = await _repository.AllInProgressByLocal(res.LocalId, res.Starttime, res.Endtime);

            var allRoomsInALocal = await _roomsRepository.GetAllByLocalId(res.LocalId);

            var takenRoomIdsUnique = reservationsInProgress.Select(x => x.RoomId).Distinct().ToList();
            var availableRoomIds   = allRoomsInALocal.Select(x => x.Id).Except(takenRoomIdsUnique).ToList();

            return(_roomsRepository.GetByID(availableRoomIds.FirstOrDefault()));
        }