public async Task <IActionResult> GetAllHotelNames() { BaseResult <List <HotelNameViewModel> > hotelNameResultFromCache = new BaseResult <List <HotelNameViewModel> > { Result = RedisCacheHelper.Instance.Get <List <HotelNameViewModel> >(Constants.CacheKeys.HotelNameList) }; if (hotelNameResultFromCache.Result == null || hotelNameResultFromCache.Result.Count == 0) { BaseResult <List <HotelView> > hotelResult = await iHotel.GetHotels().ConfigureAwait(false); if (hotelResult.IsError && hotelResult.ExceptionMessage != null) { return(new StatusCodeResult(500)); } else if (hotelResult.Result == null || hotelResult.Result.Count == 0) { return(NoContent()); //204 } else { var result = DbMapperMasterdata.MapHotels(hotelResult); RedisCacheHelper.Instance.Set <List <HotelNameViewModel> >(Constants.CacheKeys.HotelNameList, result.Result); return(Ok(result)); //200 } } return(Ok(hotelNameResultFromCache)); //200 }
public IActionResult GetHotels(Guid HotelID) { var hotels = _hotels.GetHotels(HotelID); if (hotels != null) { return(Ok(hotels)); } return(NotFound($"Hotels with id: {HotelID} was not found")); }
public async Task <IActionResult> GetAllHotelNames() { BaseResult <List <HotelNameViewModel> > hotelNameResult = new BaseResult <List <HotelNameViewModel> >(); BaseResult <List <HotelView> > hotelResult = await iHotel.GetHotels().ConfigureAwait(false); if (hotelResult.IsError && hotelResult.ExceptionMessage != null) { return(new StatusCodeResult(500)); } else if (hotelResult.Result == null || hotelResult.Result.Count == 0) { return(NoContent()); //204 } else { hotelNameResult = DbMapperMasterdata.MapHotels(hotelResult); return(Ok(hotelNameResult)); //200 } }
public async Task <ActionResult <IEnumerable <HotelsDTO> > > GetHotels() { return(Ok(await _hotel.GetHotels())); }
// GET: Hotels public async Task <IActionResult> Index() { List <Hotels> hotels = await _hotels.GetHotels(); return(View(hotels)); }