예제 #1
0
        public async Task <IActionResult> GetContinents()
        {
            continentResultFromCache = new BaseResult <List <ContinentViewModel> >
            {
                Result = RedisCacheHelper.Instance.Get <List <ContinentViewModel> >(Constants.CacheKeys.ContinentList)
            };

            if (continentResultFromCache.Result == null || continentResultFromCache.Result.Count == 0)
            {
                BaseResult <List <Continent> > continentResult = await iMasterData.GetContinents().ConfigureAwait(false);

                if (continentResult.IsError && continentResult.ExceptionMessage != null)
                {
                    return(new StatusCodeResult(500));
                }
                else if (continentResult.Result == null || continentResult.Result.Count == 0)
                {
                    return(NoContent()); //204
                }
                else
                {
                    var continentListVm = DbMapperMasterdata.MapContinent(continentResult);
                    RedisCacheHelper.Instance.Set <List <ContinentViewModel> >(Constants.CacheKeys.ContinentList, continentListVm.Result);
                    return(Ok(continentListVm)); //200
                }
            }
            return(Ok(continentResultFromCache)); //200
        }