public List <Movie> GetMovie() { if (adaptationList == null || adaptationList.Count == 0) { GetAdaptation(); } movieList = new List <Movie>(); string query = "Select * from movie"; if (this.OpenConnection() == true) { //Create Command MySqlCommand cmd = new MySqlCommand(query, connection); //Create a data reader and Execute the command MySqlDataReader dataReader = cmd.ExecuteReader(); //Read the data and store them in the list while (dataReader.Read()) { int id = int.Parse(dataReader["id"].ToString()); int duration = int.Parse(dataReader["duration"].ToString()); string filePath = dataReader["filePath"].ToString(); // NComparator for metadata needed, find element try { int index = adaptationList.IndexOf(new Adaptation(id, "", "")); //comparator only checks for id... Adaptation adaptation = adaptationList[index]; Movie movie = new Movie(adaptation, duration); if (filePath != null) { movie.FilePath = filePath; } movieList.Add(movie); } catch (Exception e) { Debug.WriteLine("There was no adaptation found for this movie:" + id); } } //close Data Reader dataReader.Close(); //close Connection this.CloseConnection(); } return(movieList); }
private void GetGenreForAdaptation(int adaptionId) { string query = "Select * from genre_adaptation where adaptation = '" + adaptionId + "'"; if (genreList == null || genreList.Count == 0) { GetGenre(); } if (adaptationList == null || adaptationList.Count == 0) { GetAdaptation(); } if (this.OpenConnection() == true) { //Create Command MySqlCommand cmd = new MySqlCommand(query, connection); //Create a data reader and Execute the command MySqlDataReader dataReader = cmd.ExecuteReader(); //Read the data and store them in the list while (dataReader.Read()) { string name = dataReader["genre"].ToString(); name = name.Trim(); Genre genre = new Genre(name); int genreIndex = genreList.IndexOf(genre); Adaptation adaptation = adaptationList[adaptationList.IndexOf(new Adaptation(adaptionId, "", ""))]; adaptation.Genre.Add(genreList[genreIndex]); } //close Data Reader dataReader.Close(); //close Connection this.CloseConnection(); } }
public Movie(Adaptation adaptation, int duration) : base(adaptation) { this.duration = duration; }
protected Adaptation(Adaptation adaptation) : base((MetaData)adaptation) { this.genre = adaptation.genre; this.franchise = adaptation.franchise; }
public void DeleteAdaptation(Adaptation adaptation) { DeleteMetaData(adaptation.Id); }
public void DeleteShow(Adaptation show) { DeleteMetaData(show.Id); }
public void AddAdaptation(Adaptation adaptation) { AddAdaptation(adaptation.Id, adaptation.Title, adaptation.OriginalTitle, adaptation.Description, adaptation.Franchise, adaptation.Genre); }
public void AddSeason(int id, string title, string originalTitle, string description, Adaptation show) { AddSeason(id, title, originalTitle, description, show.Id); }
public List <Adaptation> GetAdaptation() { if (metaDataList == null || metaDataList.Count == 0) { metaDataList = GetMetaData(); } if (franchiseList == null || franchiseList.Count == 0) { GetFranchise(); } adaptationList = new List <Adaptation>(); string query = "Select * from adaptation"; if (this.OpenConnection() == true) { //Create Command MySqlCommand cmd = new MySqlCommand(query, connection); //Create a data reader and Execute the command MySqlDataReader dataReader = cmd.ExecuteReader(); //Read the data and store them in the list while (dataReader.Read()) { int id = int.Parse(dataReader["id"].ToString()); int franchise = -1; // id cannot be negative -> -1 is not initialized (=NULL, but int cant be null) if (!dataReader.IsDBNull(1)) { franchise = int.Parse(dataReader["franchise"].ToString()); } try { int index = metaDataList.IndexOf(new MetaData(id, "")); //comparator only checks for id... MetaData meta = metaDataList[index]; Franchise adaptationFranchise = null; if (franchise != -1) { index = franchiseList.IndexOf(new Franchise("", franchise)); adaptationFranchise = franchiseList[index]; } Adaptation adaptation = new Adaptation(meta, adaptationFranchise); adaptationList.Add(adaptation); } catch (Exception e) { Debug.WriteLine("There was no metadata or franchise found for this adaptation:" + id); } } foreach (var adaption in adaptationList) { GetGenreForAdaptation(adaption.Id); } //close Data Reader dataReader.Close(); //close Connection this.CloseConnection(); } return(adaptationList); }
public Season(MetaData meta, Adaptation show) : base(meta) { this.show = show; }
public Season(int id, Adaptation show, string title) : base(id, title) { this.show = show; }
public Season(int id, Adaptation show, string title, string originalTitle, string description) : base(id, title, originalTitle, description) { this.show = show; }