public async Task <RoomDTO> GetRoom(int id, IAmenity amenity) { Room room = await _context.Rooms .Where(x => x.Id == id) .Include(x => x.RoomAmenities) .FirstOrDefaultAsync(); if (room == null) { return(null); } RoomDTO roomDTO = await _context.Rooms .Where(x => x.Id == id) .Select(x => new RoomDTO() { Id = x.Id, Name = x.Name, Layout = x.Layout }) .FirstOrDefaultAsync(); List <AmenityDTO> amenityDTOs = new List <AmenityDTO>(); foreach (RoomAmenities oneAmenity in room.RoomAmenities) { amenityDTOs.Add(await amenity.GetAmenity(oneAmenity.AmenityId)); } roomDTO.Amenities = amenityDTOs; return(roomDTO); }
/// <summary> /// Instantiates a new HotelsController object. /// </summary> /// <param name="hotel"> /// IHotel: a repository object that implements the IHotel interface /// </param> public HotelsController(IHotel hotel, IHotelRoom hotelRoom, IRoom room, IAmenity amenity) { _hotel = hotel; _hotelRoom = hotelRoom; _room = room; _amenity = amenity; }
public async Task <List <HotelRoomDTO> > GetHotelRooms(IRoom room, IAmenity amenity) { List <HotelRoomDTO> hotelRoomDTOs = await _context.HotelRooms .Select(x => new HotelRoomDTO() { HotelId = x.HotelId, RoomNumber = x.RoomNumber, RoomId = x.RoomId, Rate = x.Rate, PetFriendly = x.PetFriendly }) .ToListAsync(); if (hotelRoomDTOs.Count > 1) { foreach (HotelRoomDTO oneHotelRoomDTO in hotelRoomDTOs) { oneHotelRoomDTO.Room = await room.GetRoom(oneHotelRoomDTO.RoomId, amenity); } } return(hotelRoomDTOs); }
public async Task <List <RoomDTO> > GetRooms(IAmenity amenity) { List <Room> rooms = await _context.Rooms .Include(x => x.RoomAmenities) .ToListAsync(); List <RoomDTO> roomDTOs = new List <RoomDTO>(); foreach (Room oneRoom in rooms) { RoomDTO newRoomDTO = new RoomDTO() { Id = oneRoom.Id, Name = oneRoom.Name, Layout = oneRoom.Layout }; List <AmenityDTO> amenityDTOs = new List <AmenityDTO>(); foreach (RoomAmenities oneAmenity in oneRoom.RoomAmenities) { amenityDTOs.Add(await amenity.GetAmenity(oneAmenity.AmenityId)); } newRoomDTO.Amenities = amenityDTOs; roomDTOs.Add(newRoomDTO); } return(roomDTOs); }
public AmenitiesController(IAmenity amenity) { _amenity = amenity; }
public async Task <HotelDTO> GetHotelByName(string hotelName, IHotelRoom hotelRoom, IRoom room, IAmenity amenity) { int hotelId = await _context.Hotels .Where(x => x.Name == hotelName) .Select(x => x.Id) .FirstAsync(); return(await GetHotel(hotelId, hotelRoom, room, amenity)); }
public async Task <HotelDTO> GetHotel(int id, IHotelRoom hotelRoom, IRoom room, IAmenity amenity) { HotelDTO hotelDTO = await _context.Hotels .Where(x => x.Id == id) .Select(x => new HotelDTO { Id = x.Id, Name = x.Name, StreetAddress = x.StreetAddress, City = x.City, State = x.State, Phone = x.Phone }) .FirstAsync(); hotelDTO.Rooms = await hotelRoom.GetHotelRoomsForHotel(id, room, amenity); return(hotelDTO); }
public async Task <List <HotelDTO> > GetHotels(IHotelRoom hotelRoom, IRoom room, IAmenity amenity) { List <HotelDTO> hotelDTOs = await _context.Hotels .Select(x => new HotelDTO { Id = x.Id, Name = x.Name, StreetAddress = x.StreetAddress, City = x.City, State = x.State, Phone = x.Phone }) .ToListAsync(); foreach (HotelDTO oneHotelDTO in hotelDTOs) { oneHotelDTO.Rooms = await hotelRoom.GetHotelRoomsForHotel(oneHotelDTO.Id, room, amenity); } return(hotelDTOs); }
public RoomRepository(AsyncInnDbContext context, IAmenity amenities) { _context = context; _amenities = amenities; }
public AmenityController(IAmenity context) { _amenity = context; }
public AmenitiesController(IAmenity context) { _amenities = context; }
/// <summary> /// Instantiates a new RoomsController object. /// </summary> /// <param name="hotel"> /// IRoom: a repository object that implements the IRoom interface /// </param> public RoomsController(IRoom room, IAmenity amenity) { _room = room; _amenity = amenity; }
public async Task <HotelRoomDTO> GetRoomDetails(int hotelId, int roomNumber, IRoom room, IAmenity amenity) { HotelRoomDTO hotelRoomDTO = await _context.HotelRooms .Where(x => x.HotelId == hotelId && x.RoomNumber == roomNumber) .Select(x => new HotelRoomDTO() { HotelId = x.HotelId, RoomNumber = x.RoomNumber, RoomId = x.RoomId, Rate = x.Rate, PetFriendly = x.PetFriendly }) .FirstOrDefaultAsync(); if (hotelRoomDTO == null) { return(null); } hotelRoomDTO.Room = await room.GetRoom(hotelId, amenity); return(hotelRoomDTO); }
public async Task <List <HotelRoomDTO> > GetHotelRoomsForHotel(int hotelId, IRoom room, IAmenity amenity) { List <HotelRoomDTO> hotelRoomDTOsForHotel = await _context.HotelRooms .Where(x => x.HotelId == hotelId) .Select(x => new HotelRoomDTO() { HotelId = x.HotelId, RoomNumber = x.RoomNumber, RoomId = x.RoomId, Rate = x.Rate, PetFriendly = x.PetFriendly }) .ToListAsync(); if (hotelRoomDTOsForHotel.Count < 1) { return(null); } foreach (HotelRoomDTO oneHotelRoomDTO in hotelRoomDTOsForHotel) { oneHotelRoomDTO.Room = await room.GetRoom(oneHotelRoomDTO.RoomId, amenity); } return(hotelRoomDTOsForHotel); }
public AmenitiesController(IAmenity repository, HotelDbContext context) { this.repository = repository; }
public HotelRoomRepository(ASynceInnDbContext context, IRoom room, IAmenity amenity) { _context = context; _room = room; _amenity = amenity; }
public AmenitiesController(UserManager <ApplicationUser> userManager, IAmenity amenity) { _amenity = amenity; _userManager = userManager; }