Ejemplo n.º 1
0
 public async Task <ActionResult <IEnumerable <RoomDataModelForReservation> > > GetForReservationnAsync([FromBody] RoomsForReservationModel roomsForReservationModel)
 {
     return(Ok(await _roomService.GetForReservationAsync(roomsForReservationModel)));
 }
Ejemplo n.º 2
0
 public async Task <IEnumerable <RoomDataModelForReservation> > GetForReservationAsync(RoomsForReservationModel roomForReservationModel)
 {
     if (roomForReservationModel.DateFrom > roomForReservationModel.DateTo)
     {
         return(null);
     }
     else
     {
         return(await _roomRepository.GetRoomsForReservationAsync(roomForReservationModel));
     }
 }
Ejemplo n.º 3
0
        public async Task <IEnumerable <RoomDataModelForReservation> > GetRoomsForReservationAsync(RoomsForReservationModel roomForReservationModel)
        {
            List <Room> roomsList = await(from rooms in DBContext.Rooms.Include(r => r.Reservations).ThenInclude(r => r.ReservationInterval)
                                          where !rooms.Reservations.Where(reserv => Helpers.CheckDateOverlaps(reserv.DateFrom, reserv.DateTo, roomForReservationModel.DateFrom, roomForReservationModel.DateTo)).Any()
                                          where rooms.NumberOfPeople >= roomForReservationModel.Size
                                          where Helpers.CheckDateInside(
                                              roomForReservationModel.DateFrom.Date.AddHours(rooms.Availability.HoursFrom),
                                              roomForReservationModel.DateTo.Date.AddHours(rooms.Availability.HoursTo),
                                              roomForReservationModel.DateFrom,
                                              roomForReservationModel.DateTo)
                                          where roomForReservationModel.DateFrom.Date == roomForReservationModel.DateTo.Date
                                          select rooms
                                          ).ToListAsync();

            return(roomsList.Where(rooms => !rooms.Reservations.Where(reserv => Helpers.CheckIntervalReservation(reserv.DateFrom,
                                                                                                                 reserv.DateTo,
                                                                                                                 roomForReservationModel.DateFrom,
                                                                                                                 roomForReservationModel.DateTo,
                                                                                                                 reserv.ReservationInterval?.Time,
                                                                                                                 reserv.CyclicReservation))
                                   .Any())
                   .Select(r => new RoomDataModelForReservation
            {
                Id = r.Id,
                Name = r.Name
            }));
        }