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()); }
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()); }
public async Task <IEnumerable <Room> > GetBookingsByGuest([FromBody][Required] BookingByGuestQuery bookingQuery) { return(await hotelDAO.GetBookingByGuestAsync(bookingQuery)); }