public T Get <T>() { var details = _configurationCache?.Get <string>(typeof(T).FullName); if (!string.IsNullOrEmpty(details)) { return(ParseConfig <T>(details)); } details = _configurationRepository.Get(_options.ServiceName, _options.EnvironmentName, _options.VersionNumber); if (!string.IsNullOrEmpty(details)) { _configurationCache?.Set(typeof(T).FullName, details); } return(ParseConfig <T>(details)); }
public async Task <Model> Handle(Query request, CancellationToken cancellationToken) { var currentSeason = await _configurationCache.Get <Guid>(CacheKeys.CurrentSeasonKey); var nextSeason = await _configurationCache.Get <Guid>(CacheKeys.NextSeasonKey); var topAiringAnime = await _context.Animes .Where(x => x.SeasonId == currentSeason) .OrderBy(x => x) .ProjectTo <Model.Anime>(_mapper.ConfigurationProvider) .Take(5).ToRankedListAsync(); var topUpcomingAnime = await _context.Animes .Where(x => x.SeasonId == nextSeason) .OrderBy(x => x) .ProjectTo <Model.Anime>(_mapper.ConfigurationProvider) .Take(5).ToRankedListAsync(); var mostPopularAnime = await _context.Animes .OrderBy(x => x) .ProjectTo <Model.Anime>(_mapper.ConfigurationProvider) .Take(5).ToRankedListAsync(); var currentSeasonAnime = await _context.Animes .Where(x => x.SeasonId == currentSeason) .ProjectTo <Model.Anime>(_mapper.ConfigurationProvider) .Take(15).ToListAsync(); var recentlyUpdatedAnime = await _context.Animes .OrderBy(x => x) .ProjectTo <Model.Anime>(_mapper.ConfigurationProvider) .Take(15).ToListAsync(); return(new Model { TopAiringAnime = topAiringAnime, TopUpcomingAnime = topUpcomingAnime, MostPopularAnime = mostPopularAnime, CurrentSeasonAnime = currentSeasonAnime, RecentlyUpdatedAnime = recentlyUpdatedAnime, }); }