/*
         * Function to attempt log in to a user account
         * @PARAMETERS: - song: the song to add
         * @RETURNS: The User who has been logged in - null if unsuccesful
         * @AUTHORS: Andrew Davis and Matt Malone
         * NOTE - Commented code left in by Matt - just in case it breaks
         */
        public bool doInsertTrack(Song song, ISession session)
        {
            try
            {
                // Call to initialise cluster connection
                //init();

                ///

                Guid tid = song.getSongID();
                String artist = song.getArtist();
                String album = song.getAlbum();
                int year = song.getYear();
                String genre = song.getGenre();
                String file_loc = song.getFileLocation();
                int length = song.getLength();
                String trackname = song.getTrackName();

                // Connect to cluster
                //ISession session = cluster.Connect("maltmusic");

                //Guid tid = Guid.NewGuid();

                // Prepare and bind statement passing in username
                String todo = ("insert into tracks (\n" +
                  "track_id, artist, album, year,genre, file_loc,length,track_name)\n" +
                 "values (:tid, :art,:alb,:yr,:gnr,:floc,:len,:tnm) if not exists");

                PreparedStatement ps = session.Prepare(todo);

                BoundStatement bs = ps.Bind(tid, artist, album, year, genre, file_loc, length, trackname);

                // Execute Query
                session.Execute(bs);
                //session.Dispose();
                return true;

                // Catch exceptions
            }
            catch (Exception ex)
            {
                Console.WriteLine("SOMETHING WENT WRONG in INSERT TRACK: " + ex.Message);
                return false;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="playlist"></param>
        /// <param name="song"></param>
        /// <returns></returns>
        public bool addSongToPlaylist(Playlist playlist, Song song)
        {
            try
            {
                // Call to initialise cluster connection
                //init();

                // Connect to cluster
                ISession session = cluster.Connect("maltmusic");

                // Prepare and bind statement passing in the relevant fields
                String todo = ("insert into playlist (track_id,playlist_id,track_pos)\n" +
                 "values (:tid, :pid,:tpos) if not exists;");
                PreparedStatement ps = session.Prepare(todo);

                // Getting Appropriate ID's for query
                Guid tid = song.getSongID();
                Guid pid = playlist.getID();

                // Matt - change this
                // done
                int pos = getListPos(session, tid, pid);

                BoundStatement bs = ps.Bind(tid, pid, pos);

                // Execute Query
                session.Execute(bs);

                return true;

                // Catch exceptions
            }
            catch (Exception ex)
            {
                Console.WriteLine("SOMETHING WENT WRONG add to playlist: " + ex.Message);
                return false;
            }
        }
        public void removeSongFromPlaylist(Playlist playlist, Song song)
        {
            try
            {
                //init();
                // Connect to cluster
                ISession session = cluster.Connect("maltmusic");

                // get playlist id
                // get track id
                Guid play_id = playlist.getID();
                Guid track_id = song.getSongID();

                String todo = "delete from playlist where playlist_id = :pid and track_id = :tid";
                PreparedStatement ps = session.Prepare(todo);
                BoundStatement bs = ps.Bind(play_id, track_id);
                session.Execute(bs);
            }
            catch (Exception e)
            {
                Console.WriteLine("Removing from a plist broke " + e);
            }
        }