public List <LibraryItem.Season> getTVSeasons() { List <LibraryItem.Season> seasons = new List <Season>(); int i = 1; foreach (TMDbLib.Objects.Search.SearchTvSeason s in tvshow.Seasons) { TvSeason tvseason = new TvSeason(); tvseason = client.GetTvSeasonAsync(entryId, i, TvSeasonMethods.Credits).Result; if (tvseason.Episodes != null) { Season tmpSeason = new Season(tvseason.Name, GetTVPoster(tvseason.PosterPath), 0); foreach (TMDbLib.Objects.Search.TvSeasonEpisode e in tvseason.Episodes) { TvEpisode tvEpisode = new TvEpisode(); tvEpisode = client.GetTvEpisodeAsync(entryId, i, e.EpisodeNumber, TvEpisodeMethods.Credits).Result; List <LibraryItem.Cast> castList = GetEpisodeCast(tvEpisode); double rating = tvEpisode.VoteAverage; string name = tvEpisode.Name; DateTime release = tvEpisode.AirDate.Value; string description = tvEpisode.Overview; string poster = GetTVPoster(tvEpisode.StillPath); tmpSeason.AddEpisode(new Entry { Description = description, Name = name, Cast = castList, Release = release, Rating = rating, Poster = poster }); } seasons.Add(tmpSeason); } i++; } return(seasons); }
public List <LibraryFactory> GetAll() { List <LibraryFactory> lib = new List <LibraryFactory>(); using (SQLiteConnection cnn = new SQLiteConnection(LoadConnectionString())) { cnn.Open(); SQLiteCommand commandMovie = new SQLiteCommand("SELECT * FROM Movie", cnn); SQLiteDataReader readerMovie = commandMovie.ExecuteReader(); while (readerMovie.Read()) { int entryId = readerMovie.GetInt32(0); List <Cast> casts = new List <Cast>(); SQLiteCommand commandEntryCast = new SQLiteCommand("SELECT * FROM Entry_Cast WHERE entry_id = @entryid", cnn); commandEntryCast.Parameters.AddWithValue("@entryid", entryId); SQLiteDataReader readerEntryCast = commandEntryCast.ExecuteReader(); while (readerEntryCast.Read()) { int castId = readerEntryCast.GetInt32(1); Cast cast = new Cast(); SQLiteCommand commandCast = new SQLiteCommand("SELECT * FROM Cast WHERE cast_id = @castId", cnn); commandCast.Parameters.AddWithValue("@castId", castId); SQLiteDataReader readerCast = commandCast.ExecuteReader(); while (readerCast.Read()) { cast.Firstname = readerCast.GetString(1); cast.Role = readerCast.GetString(4); } casts.Add(cast); } LibraryFactory movie = LibraryFactory.GetLibrary(LibraryType.Movie, readerMovie.GetInt32(2), readerMovie.GetString(1)); SQLiteCommand commandEntry = new SQLiteCommand("SELECT * FROM Entry WHERE entry_id = @entryid", cnn); commandEntry.Parameters.AddWithValue("@entryid", entryId); SQLiteDataReader readerEntry = commandEntry.ExecuteReader(); while (readerEntry.Read()) { Entry entry = new Entry() { Name = readerEntry.GetString(1), Description = readerEntry.GetString(2), Release = readerEntry.GetDateTime(3), Poster = readerEntry.GetString(4), Cast = casts }; ((Movie)movie).SetEntry(entry); } lib.Add(movie); } SQLiteCommand commandSeries = new SQLiteCommand("SELECT * FROM Series", cnn); SQLiteDataReader readerSeries = commandSeries.ExecuteReader(); while (readerSeries.Read()) { LibraryFactory series = LibraryFactory.GetLibrary(LibraryType.Series, readerSeries.GetInt32(0), readerSeries.GetString(3)); ((Series)series).Description = readerSeries.GetString(2); ((Series)series).Poster = readerSeries.GetString(4); ((Series)series).Name = readerSeries.GetString(1); SQLiteCommand commandSeason = new SQLiteCommand("SELECT * FROM Season WHERE series_id = @seriesid ORDER BY season_id ASC", cnn); commandSeason.Parameters.AddWithValue("@seriesid", readerSeries.GetInt32(0)); SQLiteDataReader readerSeason = commandSeason.ExecuteReader(); while (readerSeason.Read()) { Season season = new Season(readerSeason.GetString(2), readerSeason.GetString(3)); SQLiteCommand commandEntrySeason = new SQLiteCommand("SELECT * FROM Entry_Season WHERE season_id = @seasonid ORDER BY 'index' ASC", cnn); commandEntrySeason.Parameters.AddWithValue("@seasonid", readerSeason.GetInt32(0)); SQLiteDataReader readerEntrySeason = commandEntrySeason.ExecuteReader(); while (readerEntrySeason.Read()) { int entryId = readerEntrySeason.GetInt32(0); List <Cast> casts = new List <Cast>(); SQLiteCommand commandEntryCast = new SQLiteCommand("SELECT * FROM Entry_Cast WHERE entry_id = @entryid", cnn); commandEntryCast.Parameters.AddWithValue("@entryid", entryId); SQLiteDataReader readerEntryCast = commandEntryCast.ExecuteReader(); while (readerEntryCast.Read()) { int castId = readerEntryCast.GetInt32(1); Cast cast = new Cast(); SQLiteCommand commandCast = new SQLiteCommand("SELECT * FROM Cast WHERE cast_id = @castId", cnn); commandCast.Parameters.AddWithValue("@castId", castId); SQLiteDataReader readerCast = commandCast.ExecuteReader(); while (readerCast.Read()) { cast.Firstname = readerCast.GetString(1); cast.Role = readerCast.GetString(4); } casts.Add(cast); } SQLiteCommand commandEntry = new SQLiteCommand("SELECT * FROM Entry WHERE entry_id = @entryid", cnn); commandEntry.Parameters.AddWithValue("@entryid", entryId); SQLiteDataReader readerEntry = commandEntry.ExecuteReader(); while (readerEntry.Read()) { Entry entry = new Entry() { Name = readerEntry.GetString(1), Description = readerEntry.GetString(2), Release = readerEntry.GetDateTime(3), Poster = readerEntry.GetString(4), Cast = casts }; season.AddEpisode(entry); } } ((Series)series).AddSeason(season); } lib.Add(series); } } return(lib); }