コード例 #1
0
        public List <Franchise> GetFranchise()
        {
            franchiseList = new List <Franchise>();
            string query = "Select * from franchise";

            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());
                    string    name      = dataReader["name"].ToString();
                    Franchise franchise = new Franchise(name, id);
                    franchiseList.Add(franchise);
                }

                //close Data Reader
                dataReader.Close();

                //close Connection
                this.CloseConnection();
            }

            return(franchiseList);
        }
コード例 #2
0
 public Movie(int id, string title, List <Genre> genre, Franchise franchise, int duration, string filePath) : base(id, title, genre, franchise)
 {
     this.duration = duration;
     this.filePath = filePath;
 }
コード例 #3
0
 public Movie(int id, string title, string originalTitle, string description, List <Genre> genre, Franchise franchise, int duration, string filePath) : base(id, title, originalTitle, description, genre, franchise)
 {
     this.duration = duration;
     this.filePath = filePath;
 }
コード例 #4
0
 public Movie(int id, string title, List <Genre> genre, Franchise franchise, int duration) : base(id, title, genre, franchise)
 {
     this.duration = duration;
 }
コード例 #5
0
 protected Adaptation(Adaptation adaptation) : base((MetaData)adaptation)
 {
     this.genre     = adaptation.genre;
     this.franchise = adaptation.franchise;
 }
コード例 #6
0
 public Adaptation(MetaData meta, Franchise adaptationFranchise) : base(meta)
 {
     this.franchise = adaptationFranchise;
 }
コード例 #7
0
 public Adaptation(int id, string title, List <Genre> genre, Franchise franchise) : base(id, title)
 {
     this.genre     = genre;
     this.franchise = franchise;
 }
コード例 #8
0
 public Adaptation(int id, string title, string originalTitle, string description, List <Genre> genre, Franchise franchise) : base(id, title, originalTitle, description)
 {
     this.genre     = genre;
     this.franchise = franchise;
 }
コード例 #9
0
 public void DeleteFranchise(Franchise franchise)
 {
     DeleteFranchise(franchise.Id);
 }
コード例 #10
0
 public void AddFranchise(Franchise franchise)
 {
     AddFranchise(franchise.Id, franchise.Name);
 }
コード例 #11
0
        public void AddMovie(int id, string title, string originalTitle, string description, Franchise franchise, List <Genre> genreList, int duration)
        {
            int mId;

            AddAdaptation(id, title, originalTitle, description, franchise, genreList);
            if (id >= 0)
            {
                mId = id;
            }
            else
            {
                mId = GetLastID("metadata");
            }
            string sql = "INSERT INTO `movie` (`id`, `duration`) Values('" + mId + "', '" + duration + "')";

            executeSQL(sql);
        }
コード例 #12
0
        public void AddAdaptation(int id, string title, string originalTitle, string description, Franchise franchise, List <Genre> genreList)
        {
            int mId;

            AddMetadata(id, title, originalTitle, description);
            if (id >= 0)
            {
                mId = id;
            }
            else
            {
                mId = GetLastID("metadata");
            }
            string sql = "INSERT INTO `adaptation` (`id`, `franchise`) Values('" + mId + "', '" + franchise.Id + "')";

            executeSQL(sql);

            foreach (var genre in genreList)
            {
                sql = "INSERT INTO `genre_adaptation` (`genre`, `adaptation`) Values('" + genre.Name + "', '" + mId + "')";
                executeSQL(sql);
            }
        }
コード例 #13
0
        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);
        }