// GET: Hotels/Details/5
        public async Task <IActionResult> Details(int id)
        {
            if (id.GetType() != typeof(int))
            {
                return(NotFound());
            }

            return(View(await _hotels.GetHotel(id)));
        }
Beispiel #2
0
        public async Task <ActionResult <HotelsDTO> > GetHotels(int id)
        {
            var hotels = await _hotel.GetHotel(id);

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

            return(hotels);
        }
Beispiel #3
0
        /// <summary>
        /// Get hotel by hotel id
        /// </summary>
        /// <param name="id"></param>
        /// <returns>A Task representing the asynchronous operation.</returns>
        public async Task <IActionResult> GetHotel(int id)
        {
            if (id <= 0)
            {
                return(BadRequest());
            }

            BaseResult <List <HotelView> > hotelResult = await iHotel.GetHotel(id).ConfigureAwait(false);

            if (hotelResult.Result == null || !hotelResult.Result.Any())
            {
                if (hotelResult.IsError && hotelResult.ExceptionMessage != null)
                {
                    return(new StatusCodeResult(500));
                }
                else if (hotelResult.Result == null || !hotelResult.Result.Any())
                {
                    return(NoContent()); //204
                }
            }
            HotelDetailsViewModel hotels = HotelManagementResponseMapper.MapHotelDetailsToHotelDetailsViewModel(hotelResult);

            return(Ok(hotels));
        }