Esempio n. 1
0
        public async Task <RoomDTO> GetRoom(int id)
        {
            var room = await _context.Rooms.Where(x => x.ID == id)
                       .Include(x => x.RoomAmenities)
                       .FirstOrDefaultAsync();

            RoomDTO dto = new RoomDTO
            {
                Name   = room.Name,
                Layout = room.Layout.ToString(),
                ID     = room.ID
            };

            dto.Amenities = new List <AmenityDTO>();
            foreach (var item in room.RoomAmenities)
            {
                dto.Amenities.Add(await _amenities.GetAmentity(item.AmenitiesID));
            }

            // Convert the whole Room a RoomDTO
            // some foreach loop
            // for every amentity thats in there call
            //  _amenities.GetAmentity(id)
            // which will return you a DTO
            return(dto);
        }
Esempio n. 2
0
        public async Task <ActionResult <AmenityDTO> > GetAmenities(int id)
        {
            var amenities = await _amenity.GetAmentity(id);

            if (amenities == null)
            {
                return(NotFound());
            }

            return(amenities);
        }