public Title_basics GetTitle(string id) { NpgsqlCommand cmd = OpenSqlConnection(); cmd.CommandText = $"Select * from title_basics natural join title_ratings natural join omdb_data where tconst = '{id}';"; var reader = cmd.ExecuteReader(); reader.Read(); Title_basics newTitle = new Title_basics(); newTitle.Tconst = reader.GetString(0); newTitle.TitleType = reader.GetString(1); newTitle.PrimaryTitle = reader.GetString(2); newTitle.OriginalTitle = reader.GetString(3); newTitle.IsAdult = reader.GetBoolean(4); newTitle.StartYear = reader.GetString(5); newTitle.EndYear = reader.GetString(6); newTitle.RuntimeMinutes = reader.GetInt32(7); newTitle.Genre = reader.GetString(8); newTitle.Rating = reader.GetDouble(9); newTitle.NumVotes = reader.GetInt32(10); newTitle.Poster = reader.GetString(11); newTitle.Plot = reader.GetString(12); cmd.Connection.Close(); newTitle.Writers = GetWriters(newTitle.Tconst); newTitle.Directors = GetDirectors(newTitle.Tconst); newTitle.Crew = GetCrew(newTitle.Tconst); newTitle.Title_Akas = getTitleAkas(newTitle.Tconst); return(newTitle); }
private static void Showalternativetitles(Title_basics oneTitle) { Console.WriteLine($"Alternative titles: "); foreach (Title_Akas q in oneTitle.Title_Akas) { Console.WriteLine(" - " + q.Title + " - Region: " + q.Region); } }
public List <Title_basics> searchTitles(string searchString) { NpgsqlCommand cmd = OpenSqlConnection(); cmd.CommandText = $"Select * from string_search('{searchString}');"; var reader = cmd.ExecuteReader(); var Titles = new List <Title_basics>(); while (reader.Read()) { Title_basics newTitle = new Title_basics(reader.GetString(0), reader.GetString(1)); Titles.Add(newTitle); } cmd.Connection.Close(); return(Titles); }
private static void ShowCrewForTitle(Title_basics oneTitle) { Console.WriteLine("Crew related to the title: "); foreach (Title_Principals x in oneTitle.Crew) { Console.WriteLine(""); Console.WriteLine("-----------------------------------------"); Console.WriteLine(x.Name_basics.PrimaryName); Console.WriteLine("Primary Profession : " + x.Name_basics.PrimaryProfession); Console.WriteLine("Born : " + x.Name_basics.BirthYear); Console.WriteLine("Dead : " + x.Name_basics.DeathYear); Console.WriteLine("Worked as : " + x.Job); Console.Write("Stared as : "); foreach (string role in x.Characters) { Console.Write(role + ", "); } } }
public List <Title_basics> GetSimilarTitles(String exactTitle) { var SimilarTitleList = new List <Title_basics>(); NpgsqlCommand cmd = OpenSqlConnection(); cmd.CommandText = $"Select * from similar_movies('{exactTitle}') natural join title_ratings where id = tconst"; var reader = cmd.ExecuteReader(); while (reader.Read()) { Title_basics newTitle = new Title_basics(reader.GetString(0), reader.GetString(1)); newTitle.Rating = reader.GetDouble(5); newTitle.NumVotes = reader.GetInt32(6); SimilarTitleList.Add(newTitle); } cmd.Connection.Close(); return(SimilarTitleList); }
private static void QuickTitleInfo(Title_basics oneTitle) { Console.WriteLine($"title id: {oneTitle.Tconst} - Primarytitle : {oneTitle.PrimaryTitle} - Rating : {oneTitle.Rating}"); Console.WriteLine($"year : {oneTitle.StartYear}"); Console.WriteLine($"Runtime in minutes: {oneTitle.RuntimeMinutes}"); }