Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 /// <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;
 }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
 public AmenitiesController(IAmenity amenity)
 {
     _amenity = amenity;
 }
Exemplo n.º 6
0
        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));
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
 public RoomRepository(AsyncInnDbContext context, IAmenity amenities)
 {
     _context   = context;
     _amenities = amenities;
 }
Exemplo n.º 10
0
 public AmenityController(IAmenity context)
 {
     _amenity = context;
 }
Exemplo n.º 11
0
 public AmenitiesController(IAmenity context)
 {
     _amenities = context;
 }
Exemplo n.º 12
0
 /// <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;
 }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
 public AmenitiesController(IAmenity repository, HotelDbContext context)
 {
     this.repository = repository;
 }
 public HotelRoomRepository(ASynceInnDbContext context, IRoom room, IAmenity amenity)
 {
     _context = context;
     _room    = room;
     _amenity = amenity;
 }
Exemplo n.º 17
0
 public AmenitiesController(UserManager <ApplicationUser> userManager, IAmenity amenity)
 {
     _amenity     = amenity;
     _userManager = userManager;
 }