コード例 #1
0
        // GET: Hotels/Details/5
        /// <summary>
        /// HTTP GET route for Hotels/Details/ to display a hotel details
        /// </summary>
        /// <param name="id">Hotel Id</param>
        /// <returns>Details.cshtml with a hotel details based on the Hotel Id including the rooms associated with the Hotel Id</returns>
        public async Task <IActionResult> Details(int id)
        {
            if (id <= 0)
            {
                return(NotFound());
            }

            Hotel hotel = await _hotel.GetHotelAsync(id);

            var hotelRoomsList = _hotel.GetHotelRoomsByHotel(id);

            HotelRoomsListVM hrvm = new HotelRoomsListVM();

            hrvm.Hotel      = hotel;
            hrvm.HotelRooms = hotelRoomsList;

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

            return(View(hrvm));
        }