Example #1
0
        public async Task <IEnumerable <Country> > GetAll()
        {
            // Cache Countries for 24hrs due to high page load
            return(await _cache.GetOrCreateAsync("Countries", async e =>
            {
                e.SetOptions(new MemoryCacheEntryOptions
                {
                    AbsoluteExpirationRelativeToNow = TimeSpan.FromHours(24)
                });

                try
                {
                    var countries = await Task.FromResult(MockUtil.Countries(5));
                    return countries.OrderBy(c => c.CountryName);
                }
                catch (Exception ex)
                {
                    _logger.LogError("CountryService GetAll Error", ex);
                }

                return Enumerable.Empty <Country>();
            }));
        }