Ejemplo n.º 1
0
        /// <summary>
        /// Return the Types of hotel
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> GetHotelTypes()
        {
            BaseResult <List <HotelTypeViewModel> > hotelTypeResultFromCache = new BaseResult <List <HotelTypeViewModel> >
            {
                Result = RedisCacheHelper.Instance.Get <List <HotelTypeViewModel> >(Constants.CacheKeys.HotelTypeList)
            };

            if (hotelTypeResultFromCache.Result == null || hotelTypeResultFromCache.Result.Count == 0)
            {
                BaseResult <List <HotelType> > hotelTypeResult = await iMasterData.GetHotelTypes().ConfigureAwait(false);

                if (hotelTypeResult.IsError && hotelTypeResult.ExceptionMessage != null)
                {
                    return(new StatusCodeResult(500));
                }
                else if (hotelTypeResult.Result == null || hotelTypeResult.Result.Count == 0)
                {
                    return(NoContent()); //204
                }
                else
                {
                    var hotelTypeResultAll = DbMapperMasterdata.MapHotelTypes(hotelTypeResult);
                    RedisCacheHelper.Instance.Set <List <HotelTypeViewModel> >(Constants.CacheKeys.HotelTypeList, hotelTypeResultAll.Result);
                    return(Ok(hotelTypeResultAll)); //200
                }
            }
            return(Ok(hotelTypeResultFromCache)); //200
        }