private async void GetValues() { ValuesRetrievalInProgress = true; Values.CollectionChanged -= ValuesChanged; Values.Clear(); var cache = await _cachingService.GetCache(); if (cache == null) { foreach (var value in (await _apiService.GetValueModelsAsync()).OrderBy(e => e.Order)) { Values.Add(value); } _cachingService.CacheData(Values.ToList()); } else { foreach (var value in cache) { Values.Add(value); } } Values.CollectionChanged += ValuesChanged; ((RelayCommand)CreateNewValueCommand).RaiseCanExecuteChanged(); ValuesRetrievalInProgress = false; }
public async Task <IActionResult> Get(string ytTrailerCode) { var cachedTrailer = _cachingService.GetCache(ytTrailerCode); if (cachedTrailer == null) { var trailer = await GetVideoInfoForStreamingAsync("http://www.youtube.com/watch?v=" + ytTrailerCode, YoutubeStreamingQuality.High); if (trailer != null && trailer.RequiresDecryption) { await Task.Run(() => DownloadUrlResolver.DecryptDownloadUrl(trailer)); var response = new TrailerResponse { TrailerUrl = trailer.DownloadUrl }; _cachingService.SetCache(ytTrailerCode, JsonConvert.SerializeObject(response)); return(Json(response)); } if (trailer != null && !trailer.RequiresDecryption) { var response = new TrailerResponse { TrailerUrl = trailer.DownloadUrl }; _cachingService.SetCache(ytTrailerCode, JsonConvert.SerializeObject(response)); return(Json(response)); } return(BadRequest()); } return(Json(JsonConvert.DeserializeObject <TrailerResponse>(cachedTrailer))); }
public async Task <IActionResult> Get(string imdb) { var cachedMovie = _cachingService.GetCache(imdb); if (cachedMovie == null) { using (var context = new PopcornContextFactory().Create(new DbContextFactoryOptions())) { var movie = context.MovieSet.Include(a => a.Torrents) .Include(a => a.Cast) .Include(a => a.Similars) .Include(a => a.Genres).AsQueryable() .FirstOrDefault( document => document.ImdbCode.ToLower() == imdb.ToLower()); if (movie == null) { return(BadRequest()); } var movieJson = ConvertMovieToJson(movie); _cachingService.SetCache(imdb, JsonConvert.SerializeObject(movieJson)); return(Json(movieJson)); } } return(Json(JsonConvert.DeserializeObject <MovieJson>(cachedMovie))); }
public async Task <IActionResult> Get(string imdb) { var cachedShow = _cachingService.GetCache(imdb); if (cachedShow == null) { using (var context = new PopcornContextFactory().Create(new DbContextFactoryOptions())) { var show = context.ShowSet.Include(a => a.Rating) .Include(a => a.Episodes) .ThenInclude(episode => episode.Torrents) .ThenInclude(torrent => torrent.Torrent0) .Include(a => a.Episodes) .ThenInclude(episode => episode.Torrents) .ThenInclude(torrent => torrent.Torrent1080p) .Include(a => a.Episodes) .ThenInclude(episode => episode.Torrents) .ThenInclude(torrent => torrent.Torrent480p) .Include(a => a.Episodes) .ThenInclude(episode => episode.Torrents) .ThenInclude(torrent => torrent.Torrent720p) .Include(a => a.Genres) .Include(a => a.Images) .Include(a => a.Similars).AsQueryable() .FirstOrDefault(a => a.ImdbId.ToLower() == imdb.ToLower()); if (show == null) { return(BadRequest()); } var showJson = ConvertShowToJson(show); _cachingService.SetCache(imdb, JsonConvert.SerializeObject(showJson)); return(Json(showJson)); } } return(Json(JsonConvert.DeserializeObject <ShowJson>(cachedShow))); }
public async Task <IActionResult> Get(string malid) { var cachedAnime = _cachingService.GetCache(malid); if (cachedAnime == null) { using (var context = new PopcornContextFactory().Create(new DbContextFactoryOptions())) { var anime = context.AnimeSet.Include(a => a.Rating) .Include(a => a.Episodes) .ThenInclude(episode => episode.Torrents) .ThenInclude(torrent => torrent.Torrent0) .Include(a => a.Episodes) .ThenInclude(episode => episode.Torrents) .ThenInclude(torrent => torrent.Torrent1080p) .Include(a => a.Episodes) .ThenInclude(episode => episode.Torrents) .ThenInclude(torrent => torrent.Torrent480p) .Include(a => a.Episodes) .ThenInclude(episode => episode.Torrents) .ThenInclude(torrent => torrent.Torrent720p) .Include(a => a.Genres) .Include(a => a.Images).AsQueryable().FirstOrDefault(a => a.MalId.ToLower() == malid.ToLower()); if (anime == null) { return(BadRequest()); } var animeJson = ConvertAnimeToJson(anime); _cachingService.SetCache(malid, JsonConvert.SerializeObject(animeJson)); return(Json(animeJson)); } } return(Json(JsonConvert.DeserializeObject <AnimeJson>(cachedAnime))); }
public async Task <IActionResult> Get([RequiredFromQuery] int page, [FromQuery] int limit, [FromQuery] int minimum_rating, [FromQuery] string query_term, [FromQuery] string genre, [FromQuery] string sort_by) { var nbMoviesPerPage = 20; if (limit >= 20 && limit <= 50) { nbMoviesPerPage = limit; } var currentPage = 1; if (page >= 1) { currentPage = page; } var queryTerm = string.Empty; if (!string.IsNullOrWhiteSpace(query_term)) { queryTerm = query_term; } var genreFilter = string.Empty; if (!string.IsNullOrWhiteSpace(genre)) { genreFilter = genre; } var hash = Convert.ToBase64String( Encoding.UTF8.GetBytes( $@"type=movies&page={page}&limit={limit}&minimum_rating={minimum_rating}&query_term={ query_term }&genre={genre}&sort_by={sort_by}")); try { var cachedMovies = await _cachingService.GetCache(hash); if (cachedMovies != null) { try { return(Content(cachedMovies, "application/json")); } catch (Exception ex) { _loggingService.Telemetry.TrackException(ex); } } } catch (Exception ex) { _loggingService.Telemetry.TrackException(ex); } using (var context = new PopcornContextFactory().CreateDbContext(new string[0])) { var skipParameter = new SqlParameter("@skip", (currentPage - 1) * nbMoviesPerPage); var takeParameter = new SqlParameter("@take", nbMoviesPerPage); var ratingParameter = new SqlParameter("@rating", minimum_rating); var queryParameter = new SqlParameter("@Keywords", string.Format(@"""{0}""", queryTerm)); var genreParameter = new SqlParameter("@genre", genreFilter); var query = @" SELECT DISTINCT Movie.Title, Movie.Year, Movie.Rating, Movie.PosterImage, Movie.ImdbCode, Movie.GenreNames, Torrent.Peers, Torrent.Seeds, COUNT(*) OVER () as TotalCount, Movie.DateUploadedUnix, Movie.Id, Movie.DownloadCount, Movie.LikeCount FROM MovieSet AS Movie CROSS APPLY ( SELECT TOP 1 Torrent.MovieId, Torrent.Peers, Torrent.Seeds FROM TorrentMovieSet AS Torrent WHERE Torrent.MovieId = Movie.Id AND Torrent.Url <> '' AND Torrent.Url IS NOT NULL ) Torrent INNER JOIN CastSet AS Cast ON Cast.MovieId = Movie.Id WHERE 1 = 1"; if (minimum_rating > 0 && minimum_rating < 10) { query += @" AND Rating >= @rating"; } if (!string.IsNullOrWhiteSpace(query_term)) { query += @" AND (CONTAINS(Movie.Title, @Keywords) OR CONTAINS(Cast.Name, @Keywords) OR CONTAINS(Movie.ImdbCode, @Keywords) OR CONTAINS(Cast.ImdbCode, @Keywords))"; } if (!string.IsNullOrWhiteSpace(genre)) { query += @" AND CONTAINS(Movie.GenreNames, @genre)"; } query += " GROUP BY Movie.Id, Movie.Title, Movie.Year, Movie.Rating, Movie.PosterImage, Movie.ImdbCode, Movie.GenreNames, Torrent.Peers, Torrent.Seeds, Movie.DateUploadedUnix, Movie.Id, Movie.DownloadCount, Movie.LikeCount"; if (!string.IsNullOrWhiteSpace(sort_by)) { switch (sort_by) { case "title": query += " ORDER BY Movie.Title ASC"; break; case "year": query += " ORDER BY Movie.Year DESC"; break; case "rating": query += " ORDER BY Movie.Rating DESC"; break; case "peers": query += " ORDER BY Torrent.Peers DESC"; break; case "seeds": query += " ORDER BY Torrent.Seeds DESC"; break; case "download_count": query += " ORDER BY Movie.DownloadCount DESC"; break; case "like_count": query += " ORDER BY Movie.LikeCount DESC"; break; case "date_added": query += " ORDER BY Movie.DateUploadedUnix DESC"; break; default: query += " ORDER BY Movie.DateUploadedUnix DESC"; break; } } else { query += " ORDER BY Movie.DateUploadedUnix DESC"; } query += @" OFFSET @skip ROWS FETCH NEXT @take ROWS ONLY"; var moviesQuery = await context.Database.ExecuteSqlQueryAsync(query, new CancellationToken(), skipParameter, takeParameter, ratingParameter, queryParameter, genreParameter); var reader = moviesQuery.DbDataReader; var count = 0; var movies = new List <MovieLightJson>(); while (await reader.ReadAsync()) { var movie = new MovieLightJson { Title = !await reader.IsDBNullAsync(0) ? reader.GetString(0) : string.Empty, Year = !await reader.IsDBNullAsync(1) ? reader.GetInt32(1) : 0, Rating = !await reader.IsDBNullAsync(2) ? reader.GetDouble(2) : 0d, PosterImage = !await reader.IsDBNullAsync(3) ? reader.GetString(3) : string.Empty, ImdbCode = !await reader.IsDBNullAsync(4) ? reader.GetString(4) : string.Empty, Genres = !await reader.IsDBNullAsync(5) ? reader.GetString(5) : string.Empty }; movies.Add(movie); count = !await reader.IsDBNullAsync(8) ? reader.GetInt32(8) : 0; } var response = new MovieLightResponse { TotalMovies = count, Movies = movies }; var json = JsonSerializer.ToJsonString(response, StandardResolver.SnakeCase); await _cachingService.SetCache(hash, json, TimeSpan.FromDays(1)); return(Content(json, "application/json")); } }
public async Task <IActionResult> Get([RequiredFromQuery] int page, [FromQuery] int limit, [FromQuery] int minimum_rating, [FromQuery] string query_term, [FromQuery] string genre, [FromQuery] string sort_by) { var nbShowsPerPage = 20; if (limit >= 20 && limit <= 50) { nbShowsPerPage = limit; } var currentPage = 1; if (page >= 1) { currentPage = page; } var queryTerm = string.Empty; if (!string.IsNullOrWhiteSpace(query_term)) { queryTerm = query_term; } var genreFilter = string.Empty; if (!string.IsNullOrWhiteSpace(genre)) { genreFilter = genre; } var hash = Convert.ToBase64String( Encoding.UTF8.GetBytes( $@"type=shows&page={page}&limit={limit}&minimum_rating={minimum_rating}&query_term={ query_term }&genre={genre}&sort_by={sort_by}")); try { var cachedShows = await _cachingService.GetCache(hash); if (cachedShows != null) { try { return(Json(JsonConvert.DeserializeObject <ShowLightResponse>(cachedShows))); } catch (Exception ex) { _loggingService.Telemetry.TrackException(ex); } } } catch (Exception ex) { _loggingService.Telemetry.TrackException(ex); } using (var context = new PopcornContextFactory().CreateDbContext(new string[0])) { var skipParameter = new SqlParameter("@skip", (currentPage - 1) * nbShowsPerPage); var takeParameter = new SqlParameter("@take", nbShowsPerPage); var ratingParameter = new SqlParameter("@rating", minimum_rating); var queryParameter = new SqlParameter("@Keywords", queryTerm); var genreParameter = new SqlParameter("@genre", genreFilter); var query = @" SELECT Show.Title, Show.Year, Rating.Percentage, Rating.Loved, Rating.Votes, Rating.Hated, Rating.Watching, Show.LastUpdated, Image.Banner, Image.Fanart, Image.Poster, Show.ImdbId, Show.TvdbId, Show.GenreNames, COUNT(*) OVER () as TotalCount FROM ShowSet AS Show INNER JOIN ImageShowSet AS Image ON Image.Id = Show.ImagesId INNER JOIN RatingSet AS Rating ON Rating.Id = Show.RatingId WHERE 1 = 1"; if (minimum_rating > 0 && minimum_rating < 10) { query += @" AND Rating >= @rating"; } if (!string.IsNullOrWhiteSpace(query_term)) { query += @" AND FREETEXT(Title, @Keywords)"; } if (!string.IsNullOrWhiteSpace(genre)) { query += @" AND CONTAINS(GenreNames, @genre)"; } if (!string.IsNullOrWhiteSpace(sort_by)) { switch (sort_by) { case "title": query += " ORDER BY Show.Title ASC"; break; case "year": query += " ORDER BY Show.Year DESC"; break; case "rating": query += " ORDER BY Rating.Percentage DESC"; break; case "loved": query += " ORDER BY Rating.Loved DESC"; break; case "votes": query += " ORDER BY Rating.Votes DESC"; break; case "watching": query += " ORDER BY Rating.Watching DESC"; break; case "date_added": query += " ORDER BY Show.LastUpdated DESC"; break; default: query += " ORDER BY Show.LastUpdated DESC"; break; } } else { query += " ORDER BY Show.LastUpdated DESC"; } query += @" OFFSET @skip ROWS FETCH NEXT @take ROWS ONLY"; var showsQuery = await context.Database.ExecuteSqlQueryAsync(query, new CancellationToken(), skipParameter, takeParameter, ratingParameter, queryParameter, genreParameter); var reader = showsQuery.DbDataReader; var count = 0; var shows = new List <ShowLightJson>(); while (await reader.ReadAsync()) { var show = new ShowLightJson { Title = reader[0].GetType() != typeof(DBNull) ? (string)reader[0] : string.Empty, Year = reader[1].GetType() != typeof(DBNull) ? (int)reader[1] : 0, Rating = new RatingJson { Percentage = reader[2].GetType() != typeof(DBNull) ? (int)reader[2] : 0, Loved = reader[3].GetType() != typeof(DBNull) ? (int)reader[3] : 0, Votes = reader[4].GetType() != typeof(DBNull) ? (int)reader[4] : 0, Hated = reader[5].GetType() != typeof(DBNull) ? (int)reader[5] : 0, Watching = reader[6].GetType() != typeof(DBNull) ? (int)reader[6] : 0 }, Images = new ImageShowJson { Banner = reader[8].GetType() != typeof(DBNull) ? (string)reader[8] : string.Empty, Fanart = reader[9].GetType() != typeof(DBNull) ? (string)reader[9] : string.Empty, Poster = reader[10].GetType() != typeof(DBNull) ? (string)reader[10] : string.Empty, }, ImdbId = reader[11].GetType() != typeof(DBNull) ? (string)reader[11] : string.Empty, TvdbId = reader[12].GetType() != typeof(DBNull) ? (string)reader[12] : string.Empty, Genres = reader[13].GetType() != typeof(DBNull) ? (string)reader[13] : string.Empty }; shows.Add(show); count = reader[14].GetType() != typeof(DBNull) ? (int)reader[14] : 0; } var response = new ShowLightResponse { TotalShows = count, Shows = shows }; await _cachingService.SetCache(hash, JsonConvert.SerializeObject(response), TimeSpan.FromDays(1)); return (Json(response)); } }
public async Task <IActionResult> Get([RequiredFromQuery] int page, [FromQuery] int limit, [FromQuery] int minimum_rating, [FromQuery] string query_term, [FromQuery] string genre, [FromQuery] string sort_by) { var nbMoviesPerPage = 20; if (limit >= 20 && limit <= 50) { nbMoviesPerPage = limit; } var currentPage = 1; if (page >= 1) { currentPage = page; } var queryTerm = string.Empty; if (!string.IsNullOrWhiteSpace(query_term)) { queryTerm = query_term; } var genreFilter = string.Empty; if (!string.IsNullOrWhiteSpace(genre)) { genreFilter = genre; } var hash = Convert.ToBase64String( Encoding.UTF8.GetBytes( $@"type=movies&page={page}&limit={limit}&minimum_rating={minimum_rating}&query_term={ query_term }&genre={genre}&sort_by={sort_by}")); try { var cachedMovies = await _cachingService.GetCache(hash); if (cachedMovies != null) { try { return(Json(JsonConvert.DeserializeObject <MovieLightResponse>(cachedMovies))); } catch (Exception ex) { _loggingService.Telemetry.TrackException(ex); } } } catch (Exception ex) { _loggingService.Telemetry.TrackException(ex); } using (var context = new PopcornContextFactory().CreateDbContext(new string[0])) { var skipParameter = new SqlParameter("@skip", (currentPage - 1) * nbMoviesPerPage); var takeParameter = new SqlParameter("@take", nbMoviesPerPage); var ratingParameter = new SqlParameter("@rating", minimum_rating); var queryParameter = new SqlParameter("@Keywords", queryTerm); var genreParameter = new SqlParameter("@genre", genreFilter); var query = @" SELECT Movie.Title, Movie.Year, Movie.Rating, Movie.PosterImage, Movie.ImdbCode, Movie.GenreNames, Torrent.Peers, Torrent.Seeds, COUNT(*) OVER () as TotalCount FROM MovieSet AS Movie INNER JOIN TorrentMovieSet AS Torrent ON Torrent.MovieId = Movie.Id AND Torrent.Quality = '720p' WHERE 1 = 1"; if (minimum_rating > 0 && minimum_rating < 10) { query += @" AND Rating >= @rating"; } if (!string.IsNullOrWhiteSpace(query_term)) { query += @" AND FREETEXT(Title, @Keywords)"; } if (!string.IsNullOrWhiteSpace(genre)) { query += @" AND CONTAINS(GenreNames, @genre)"; } if (!string.IsNullOrWhiteSpace(sort_by)) { switch (sort_by) { case "title": query += " ORDER BY Movie.Title ASC"; break; case "year": query += " ORDER BY Movie.Year DESC"; break; case "rating": query += " ORDER BY Movie.Rating DESC"; break; case "peers": query += " ORDER BY Torrent.Peers DESC"; break; case "seeds": query += " ORDER BY Torrent.Seeds DESC"; break; case "download_count": query += " ORDER BY Movie.DownloadCount DESC"; break; case "like_count": query += " ORDER BY Movie.LikeCount DESC"; break; case "date_added": query += " ORDER BY Movie.DateUploadedUnix DESC"; break; default: query += " ORDER BY Movie.DateUploadedUnix DESC"; break; } } else { query += " ORDER BY Movie.DateUploadedUnix DESC"; } query += @" OFFSET @skip ROWS FETCH NEXT @take ROWS ONLY"; var moviesQuery = await context.Database.ExecuteSqlQueryAsync(query, new CancellationToken(), skipParameter, takeParameter, ratingParameter, queryParameter, genreParameter); var reader = moviesQuery.DbDataReader; var count = 0; var movies = new List <MovieLightJson>(); while (await reader.ReadAsync()) { var movie = new MovieLightJson { Title = reader[0].GetType() != typeof(DBNull) ? (string)reader[0] : string.Empty, Year = reader[1].GetType() != typeof(DBNull) ? (int)reader[1] : 0, Rating = reader[2].GetType() != typeof(DBNull) ? (double)reader[2] : 0d, PosterImage = reader[3].GetType() != typeof(DBNull) ? (string)reader[3] : string.Empty, ImdbCode = reader[4].GetType() != typeof(DBNull) ? (string)reader[4] : string.Empty, Genres = reader[5].GetType() != typeof(DBNull) ? (string)reader[5] : string.Empty }; movies.Add(movie); count = reader[8].GetType() != typeof(DBNull) ? (int)reader[8] : 0; } var response = new MovieLightResponse { TotalMovies = count, Movies = movies }; await _cachingService.SetCache(hash, JsonConvert.SerializeObject(response), TimeSpan.FromDays(1)); return (Json(response)); } }
public async Task <IActionResult> Get([RequiredFromQuery] int page, [FromQuery] int limit, [FromQuery] int minimum_rating, [FromQuery] string query_term, [FromQuery] string genre, [FromQuery] string sort_by) { var nbShowsPerPage = 20; if (limit >= 20 && limit <= 50) { nbShowsPerPage = limit; } var currentPage = 1; if (page >= 1) { currentPage = page; } var queryTerm = string.Empty; if (!string.IsNullOrWhiteSpace(query_term)) { queryTerm = query_term; } var genreFilter = string.Empty; if (!string.IsNullOrWhiteSpace(genre)) { genreFilter = genre; } var hash = Convert.ToBase64String( Encoding.UTF8.GetBytes( $@"type=shows&page={page}&limit={limit}&minimum_rating={minimum_rating}&query_term={ query_term }&genre={genre}&sort_by={sort_by}")); try { var cachedShows = await _cachingService.GetCache(hash); if (cachedShows != null) { try { return(Content(cachedShows, "application/json")); } catch (Exception ex) { _loggingService.Telemetry.TrackException(ex); } } } catch (Exception ex) { _loggingService.Telemetry.TrackException(ex); } using (var context = new PopcornContextFactory().CreateDbContext(new string[0])) { var skipParameter = new SqlParameter("@skip", (currentPage - 1) * nbShowsPerPage); var takeParameter = new SqlParameter("@take", nbShowsPerPage); var ratingParameter = new SqlParameter("@rating", minimum_rating); var queryParameter = new SqlParameter("@Keywords", string.Format(@"""{0}""", queryTerm)); var genreParameter = new SqlParameter("@genre", genreFilter); var query = @" SELECT Show.Title, Show.Year, Rating.Percentage, Rating.Loved, Rating.Votes, Rating.Hated, Rating.Watching, Show.LastUpdated, Image.Banner, Image.Poster, Show.ImdbId, Show.TvdbId, Show.GenreNames, COUNT(*) OVER () as TotalCount FROM ShowSet AS Show INNER JOIN ImageShowSet AS Image ON Image.Id = Show.ImagesId INNER JOIN RatingSet AS Rating ON Rating.Id = Show.RatingId WHERE Show.NumSeasons <> 0"; if (minimum_rating > 0 && minimum_rating < 10) { query += @" AND Rating >= @rating"; } if (!string.IsNullOrWhiteSpace(query_term)) { query += @" AND (CONTAINS(Title, @Keywords) OR CONTAINS(ImdbId, @Keywords) OR CONTAINS(TvdbId, @Keywords))"; } if (!string.IsNullOrWhiteSpace(genre)) { query += @" AND CONTAINS(GenreNames, @genre)"; } if (!string.IsNullOrWhiteSpace(sort_by)) { switch (sort_by) { case "title": query += " ORDER BY Show.Title ASC"; break; case "year": query += " ORDER BY Show.Year DESC"; break; case "rating": query += " ORDER BY Rating.Percentage DESC"; break; case "loved": query += " ORDER BY Rating.Loved DESC"; break; case "votes": query += " ORDER BY Rating.Votes DESC"; break; case "watching": query += " ORDER BY Rating.Watching DESC"; break; case "date_added": query += " ORDER BY Show.LastUpdated DESC"; break; default: query += " ORDER BY Show.LastUpdated DESC"; break; } } else { query += " ORDER BY Show.LastUpdated DESC"; } query += @" OFFSET @skip ROWS FETCH NEXT @take ROWS ONLY"; var showsQuery = await context.Database.ExecuteSqlQueryAsync(query, new CancellationToken(), skipParameter, takeParameter, ratingParameter, queryParameter, genreParameter); var reader = showsQuery.DbDataReader; var count = 0; var shows = new List <ShowLightJson>(); while (await reader.ReadAsync()) { var show = new ShowLightJson { Title = !await reader.IsDBNullAsync(0) ? reader.GetString(0) : string.Empty, Year = !await reader.IsDBNullAsync(1) ? reader.GetInt32(1) : 0, Rating = new RatingJson { Percentage = !await reader.IsDBNullAsync(2) ? reader.GetInt32(2) : 0, Loved = !await reader.IsDBNullAsync(3) ? reader.GetInt32(3) : 0, Votes = !await reader.IsDBNullAsync(4) ? reader.GetInt32(4) : 0, Hated = !await reader.IsDBNullAsync(5) ? reader.GetInt32(5) : 0, Watching = !await reader.IsDBNullAsync(6) ? reader.GetInt32(6) : 0 }, Images = new ImageShowJson { Banner = !await reader.IsDBNullAsync(8) ? reader.GetString(8) : string.Empty, Poster = !await reader.IsDBNullAsync(9) ? reader.GetString(9) : string.Empty, }, ImdbId = !await reader.IsDBNullAsync(10) ? reader.GetString(10) : string.Empty, TvdbId = !await reader.IsDBNullAsync(11) ? reader.GetString(11) : string.Empty, Genres = !await reader.IsDBNullAsync(12) ? reader.GetString(12) : string.Empty }; shows.Add(show); count = !await reader.IsDBNullAsync(13) ? reader.GetInt32(13) : 0; } var response = new ShowLightResponse { TotalShows = count, Shows = shows }; var json = JsonSerializer.ToJsonString(response, StandardResolver.SnakeCase); await _cachingService.SetCache(hash, json, TimeSpan.FromDays(1)); return(Content(json, "application/json")); } }