コード例 #1
0
        public void CreatePlaylist(Playlist playlist)
        {
            if (playlist.IsPlaylistTooBig())
                throw new Exception("Too Big");

            _playlistRepository.CreatePlaylist(playlist);
        }
コード例 #2
0
        public int CreatePlaylist(Playlist playlist)
        {
            var insert = @"INSERT INTO dbo.Playlist VALUES(PlaylistName)
            VALUES (@playlistName); SELECT CAST(SCOPE_IDENTITY() as int;";

            var playlistId = _database.ExecuteScalar<int>(insert, new { playlistName = playlist.PlaylistName});

            foreach (var t in playlist.Tracks)
            {
                CreateTrack(playlistId, t);
            }

            return playlistId;
        }
コード例 #3
0
 public IEnumerable<Track> GetTracksInPlaylist(Playlist playlist)
 {
     return _playlistRepository.GetAllPlaylists().SelectMany(p => p.Tracks);
 }