Beispiel #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            CDCatalogProcess.GeneratePlayList("Winforms Test Playlist", 120);

            Playlist            playlist = CDCatalogManager.GetPlaylists().Where(p => p.PlaylistName.Equals("Winforms Test Playlist")).Last();
            List <PlaylistSong> pl       = CDCatalogManager.GetPlaylistSongs().Where(p => p.PlaylistID.Equals(playlist.PlaylistID)).ToList();
            List <Song>         songs    = new List <Song>();
            int totalDuration            = 0;

            foreach (PlaylistSong pls in pl)
            {
                songs.Add(CDCatalogManager.GetSongs().Where(s => s.SongID.Equals(pls.SongID)).First());
                totalDuration += (CDCatalogManager.GetSongs().Where(s => s.SongID.Equals(pls.SongID)).First()).TrackLength;
            }

            dataGridView1.DataSource = songs;
            textBox1.Text            = "Total playlist duration is " + totalDuration.ToString() + " seconds.";


            //using (CDCatalogEntities db = new CDCatalogEntities())
            //{
            //    Playlist playList = new Playlist();
            //    playList.PlaylistName = "Test Playlist";
            //    db.Playlists.Add(playList);
            //    db.SaveChanges();

            //    List<PlaylistSong> playlistSongList = new List<PlaylistSong>();
            //    int targetMinutes = 12000;
            //    int targetSeconds = (targetMinutes * 60);

            //    List<Song> songList = db.Songs.OrderByDescending(s => s.TrackLength).ToList();

            //    playlistSongList = RandomPlaylist(songList, targetSeconds, playList);

            //    List<PlaylistSong> pl = db.PlaylistSongs.Where(p => p.PlaylistID.Equals(playList.PlaylistID)).ToList();
            //    List<Song> songs = new List<Song>();
            //}
        }