Example #1
0
        private Playlist CreateLinks(Playlist playlist)
        {
            playlist.Links.Add(new Link(_urlHelper.Link("GetPlaylist",
                                                        new { id = playlist.Id }),
                                        "self",
                                        "GET"));

            playlist.Links.Add(
                new Link(_urlHelper.Link("DeletePlaylist",
                                         new { id = playlist.Id }),
                         "delete_playlist",
                         "DELETE"));

            playlist.Links.Add(
                new Link(_urlHelper.Link("GetSongsFromPlaylist",
                                         new { playlistId = playlist.Id }),
                         "songs",
                         "GET"));

            playlist.Links.Add(
                new Link(_urlHelper.Link("AddSongToPlaylist",
                                         new { playlistId = playlist.Id }),
                         "add_song_to_playlist",
                         "POST"));

            // rule: if a playlist has more than 3 songs, we can rate it.
            if (_sprotifyRepository.GetSongCount(playlist.Id) > 3)
            {
                playlist.Links.Add(
                    new Link(_urlHelper.Link("RatePlaylist",
                                             new { id = playlist.Id }),
                             "rate_playlist",
                             "POST"));
            }

            return(playlist);
        }