Esempio n. 1
0
 protected void BtnNewPlaylistClicked(object sender, EventArgs e)
 {
     List<Playlist> playlistList = databaseManager.GetAllPlaylists();
     int hightestPlaylistID = 0;
     foreach (Playlist p in playlistList)
     {
         if (p.PlaylistID >= hightestPlaylistID)
         {
             hightestPlaylistID = p.PlaylistID + 1;
         }
     }
     if (tbPlaylistName.Text != string.Empty)
     {
     Playlist playlist = new Playlist(hightestPlaylistID,currentUser,tbPlaylistName.Text);
     databaseManager.NewPlaylist(playlist);
     Page.Response.Redirect(HttpContext.Current.Request.Url.ToString(), true);
     }
 }
Esempio n. 2
0
        public List<Playlist> GetPlaylists(string username)
        {
            List<Playlist> playlistList = new List<Playlist>();
            if (connection.State != ConnectionState.Open)
            {
                connection.Open();
            }
            string query = "SELECT afspeellijstID,NAAM FROM SE_Afspeellijst WHERE gebruikersnaam = :userName";

            OracleCommand command = new OracleCommand(query, connection);
            command.CommandType = CommandType.Text;

            command.Parameters.Add("userName", username);
            OracleDataReader dataReader;
            int playlistID = 0;
            string name = string.Empty;
            try
            {
                dataReader = command.ExecuteReader();
                while (dataReader.Read())
                {
                    playlistID = Convert.ToInt32(dataReader["AFSPEELLIJSTID"]);
                    name = Convert.ToString(dataReader["NAAM"]);
                    Playlist playlist = new Playlist(playlistID,GetUser(username),name);
                    playlistList.Add(playlist);
                }

            }
            catch
            {
                // Catch if reading from the database doesn't work
            }
            connection.Close();
            return playlistList;
        }
Esempio n. 3
0
        public bool NewPlaylist(Playlist playlist)
        {
            //List<Comment> comments = GetComments(video);
            //int commentID = comments.Count() + 1;
            string query = "INSERT INTO SE_AFSPEELLIJST (AFSPEELLIJSTID,GEBRUIKERSNAAM,NAAM) VALUES (:playlistID,:username,:playlistName)";
            // Located lower than usual, because GetComments(video) would close the connection.
            if (connection.State != ConnectionState.Open)
            {
                connection.Open();
            }
            OracleCommand command = new OracleCommand(query, connection);
            command.CommandType = CommandType.Text;
            command.Parameters.Add("playlistID", playlist.PlaylistID);
            command.Parameters.Add("username", playlist.User.Username);
            command.Parameters.Add("playlistName", playlist.Name);

            try
            {
                command.ExecuteNonQuery();
            }
            catch
            {
                return false;
                // Catch if the command was not succesfully executed.
            }
            connection.Close();
            return true;
        }
Esempio n. 4
0
 public List<Playlist> GetAllPlaylists()
 {
     List<Playlist> PlaylistList = new List<Playlist>();
     if (connection.State != ConnectionState.Open)
     {
         connection.Open();
     }
     string query = "SELECT * FROM SE_AFSPEELLIJST";
     OracleCommand command = new OracleCommand(query, connection);
     command.CommandType = CommandType.Text;
     OracleDataReader dataReader;
     int playlistId = 0;
     string username = string.Empty;
     string name = string.Empty;
     try
     {
         dataReader = command.ExecuteReader();
         while (dataReader.Read())
         {
             playlistId= Convert.ToInt32(dataReader["AFSPEELLIJSTID"]);
             username = Convert.ToString(dataReader["GEBRUIKERSNAAM"]);
             name = Convert.ToString(dataReader["NAAM"]);
             Playlist playlist = new Playlist(playlistId, GetUser(username), name);
             PlaylistList.Add(playlist);
         }
     }
     catch
     {
         // Catch if reading from the database doesn't work
     }
     connection.Close();
     return PlaylistList;
 }