public void CreatePlaylist(Playlist playlist) { if (playlist.IsPlaylistTooBig()) throw new Exception("Too Big"); _playlistRepository.CreatePlaylist(playlist); }
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; }
public IEnumerable<Track> GetTracksInPlaylist(Playlist playlist) { return _playlistRepository.GetAllPlaylists().SelectMany(p => p.Tracks); }