/// <summary> /// gets a single hotel /// </summary> /// <param name="id">hotel identifier</param> /// <returns>task completion </returns> public async Task <HotelDTO> GetHotel(int id) { // looks into the db and finds the object with the same id Hotel hotel = await _context.Hotels.Where(x => x.Id == id) .Include(x => x.HotelRooms) .ThenInclude(x => x.room) .ThenInclude(x => x.RoomAmenities) .ThenInclude(x => x.amenity) .FirstOrDefaultAsync(); List <HotelRoomDTO> hotelroom = await _hotelroom.GetHotelRooms(id); HotelDTO hoteldto = new HotelDTO() { Name = hotel.Name, StreetAddress = hotel.StreetAddress, City = hotel.City, State = hotel.State, Phone = hotel.Phone, HotelRooms = hotelroom }; return(hoteldto); }
// Get individually (by Id) /// <summary> /// Gets a single hotel from the table /// </summary> /// <param name="id">Integer for the id</param> /// <returns>the hotelDTO object</returns> public async Task <HotelDTO> GetHotel(int id) { Hotel hotel = await _context.Hotels.Where(x => x.Id == id) .Include(x => x.HotelRooms) .ThenInclude(x => x.Room) .ThenInclude(x => x.RoomAmenities) .ThenInclude(x => x.Amenity) .FirstOrDefaultAsync(); List <HotelRoomDTO> hotelRooms = await _hotelRoom.GetHotelRooms(id); HotelDTO hotelDTO = new HotelDTO() { ID = hotel.Id, Name = hotel.Name, StreetAddress = hotel.StreetAddress, City = hotel.City, State = hotel.State, Phone = hotel.Phone, Rooms = hotelRooms }; return(hotelDTO); }
/// <summary> /// Returns the specified hotel and a list of all of the rooms, room amenities, and amenities /// associated with the hotel in the Hotels database table. /// </summary> /// <param name="id">Unique identifier of the hotel</param> /// <returns>The specified hotel and a list of all of the associated /// rooms, room amenities, and amenities</returns> public async Task <HotelDTO> GetHotel(int id) { // Look in the DB on the Hotel table, // where the id is equal to the id that was brought in as an argument var hotel = await _context.Hotels.Where(h => h.Id == id) .Include(h => h.HotelRooms) .ThenInclude(hr => hr.Room) .ThenInclude(r => r.RoomAmenities) .ThenInclude(ra => ra.Amenity) .FirstOrDefaultAsync(); HotelDTO hotelDto = ConvertHotelIntoDTO(hotel); hotelDto.Rooms = await _hotelRoom.GetHotelRooms(hotel.Id); return(hotelDto); }
/// <summary> /// Finds the Hotel that matches the ID /// </summary> /// <param name="id">The ID of the Hotel to be found</param> /// <returns>The requested Hotel</returns> public async Task <HotelDTO> GetHotel(int id) { Hotel hotel = await _context.Hotels.FindAsync(id); var hotelRoomDTO = await _HotelRoom.GetHotelRooms(hotel.Id); HotelDTO hotelDTO = new HotelDTO() { ID = hotel.Id, Name = hotel.Name, StreetAddress = hotel.StretAddress, City = hotel.City, State = hotel.State, Phone = hotel.PhoneNumber, Rooms = hotelRoomDTO }; // TODO: Need to add Navigation properties to HotelDTO return(hotelDTO); }
public async Task <IEnumerable <HotelRoom> > GetHotelRooms() { return(await _hotelRoomRepo.GetHotelRooms()); }
public async Task <ActionResult <IEnumerable <HotelRoomDTO> > > GetHotelRooms(int hotelId) { return(await _hotelRoom.GetHotelRooms(hotelId)); }
public async Task <ActionResult <IEnumerable <HotelRoom> > > GetHotelRooms() { return(await _hotelRoom.GetHotelRooms()); }
public async Task <ActionResult <IEnumerable <HotelRoomDTO> > > GetHotelRooms() { return(await _hotelRoom.GetHotelRooms(_room, _amenity)); }