/// <summary>
        /// Return the list of Markets
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> GetMarkets()
        {
            BaseResult <List <MarketViewModel> > marketResultFromCache = new BaseResult <List <MarketViewModel> >
            {
                Result = RedisCacheHelper.Instance.Get <List <MarketViewModel> >(Constants.CacheKeys.MarketList)
            };

            if (marketResultFromCache.Result == null || marketResultFromCache.Result.Count == 0)
            {
                BaseResult <List <Market> > marketResult = await iRatesCategory.GetMarkets().ConfigureAwait(false);

                if (marketResult.IsError && marketResult.ExceptionMessage != null)
                {
                    return(new StatusCodeResult(500));
                }
                else if (marketResult.Result == null || marketResult.Result.Count == 0)
                {
                    return(NoContent()); //204
                }
                else
                {
                    var result = RatesCategoryResponseMapper.MapMarket(marketResult);
                    RedisCacheHelper.Instance.Set <List <MarketViewModel> >(Constants.CacheKeys.MarketList, result.Result);
                    return(Ok(result)); //200
                }
            }
            return(Ok(marketResultFromCache)); //200
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Return the list of Markets
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> GetMarkets()
        {
            BaseResult <List <Market> > marketResult = await iRatesCategory.GetMarkets().ConfigureAwait(false);

            if (marketResult.IsError && marketResult.ExceptionMessage != null)
            {
                return(new StatusCodeResult(500));
            }
            else if (marketResult.Result == null || marketResult.Result.Count == 0)
            {
                return(NoContent()); //204
            }
            var result = RatesCategoryResponseMapper.MapMarket(marketResult);

            return(Ok(result)); //200
        }