コード例 #1
0
        public async Task <IEnumerable <Room> > GetBookingByGuestAsync(BookingByGuestQuery bookingQuery)
        {
            IEnumerable <RoomBookingByGuest> result = await mapper.FetchAsync <RoomBookingByGuest>("WHERE guest_id = ?", bookingQuery.GuestId);

            return(result.ToList().Where(b =>
                                         (b.StartReserveTime >= bookingQuery.StartReserveTime &&
                                          b.StartReserveTime <= bookingQuery.EndReserveTime) ||
                                         (b.EndReserveTime >= bookingQuery.StartReserveTime &&
                                          b.EndReserveTime <= b.EndReserveTime))
                   .Select(r => new Room(r))
                   .ToList());
        }
コード例 #2
0
        public async Task <IEnumerable <Room> > GetBookingsByGuestAsync([FromBody][Required] BookingByGuestQuery bookingQuery)
        {
            IEnumerable <Guest> resultGuests = await UnitOfWork.Guest.GetByIdAsync(bookingQuery.GuestId.Value);

            List <Guest> guests = resultGuests.ToList();

            if (!guests.Any())
            {
                throw new Exception("Provided guest does not exist");
            }
            IEnumerable <RoomBookingByGuest> result = await UnitOfWork.RoomBooking.GetByGuestIdAsync(bookingQuery.GuestId.Value);

            return(result.ToList().Where(b =>
                                         (b.StartReserveTime >= bookingQuery.StartReserveTime &&
                                          b.StartReserveTime <= bookingQuery.EndReserveTime) ||
                                         (b.EndReserveTime >= bookingQuery.StartReserveTime &&
                                          b.EndReserveTime <= b.EndReserveTime))
                   .Select(r => (Room)r)
                   .ToList());
        }
コード例 #3
0
 public async Task <IEnumerable <Room> > GetBookingsByGuest([FromBody][Required] BookingByGuestQuery bookingQuery)
 {
     return(await hotelDAO.GetBookingByGuestAsync(bookingQuery));
 }