Beispiel #1
0
        public IActionResult GetCountriesJsonDataString()
        {
            string CountryCodesAndNames = string.Empty;

            if (!_memoryCache.TryGetValue(Constants.COUNTRIES, out CountryCodesAndNames))
            {
                CountryCodesAndNames = _readService.GetJsonDataFromFile(_countriesFileName);
                var opts = new MemoryCacheEntryOptions
                {
                    SlidingExpiration = TimeSpan.FromDays(Convert.ToInt32(_config["InMemoryCacheDays"]))
                };
                _memoryCache.Set(Constants.COUNTRIES, CountryCodesAndNames, opts);
            }

            if (string.IsNullOrEmpty(CountryCodesAndNames))
            {
                return(NotFound());
            }
            return(Ok(CountryCodesAndNames));
        }