示例#1
0
        private void AddPlaylist(object sender, RoutedEventArgs e)
        {
            // get list of currentPlaylists
            string playlists = makeRequest("api=pl");

            if (playlists != null && !string.IsNullOrWhiteSpace(playlists))
            {
                string       name;
                PlaylistName dl = new PlaylistName();
                dl.ShowDialog();
                if (dl.DialogResult != true)
                {
                    return;
                }
                name = dl.Name;
                if (name != null && !string.IsNullOrWhiteSpace(name))
                {
                    char[] sep = { '\n' };
                    if (!playlists.Split(sep).Contains(name))
                    {
                        string quaryString = "nores=create&item=" + name;
                        makeRequest(quaryString);
                        PlaylistsList.Add(new playlist(name));
                        NotifyPropertyChanged("PlaylistsList");
                    }
                    else
                    {
                        MessageBox.Show("There is already a playlist with this name!");
                    }
                }
            }
        }
        public async Task Init(PlaylistSearchRequest request = null)
        {
            PlaylistsList.Clear();
            try
            {
                var UserID = SignedInUserHelper.User.ID;

                var playlists = await _service.GetActivityPlaylists(UserID, request);

                foreach (var playlist in playlists)
                {
                    PlaylistsList.Add(playlist);
                }
            }
            catch
            {
            }
        }
        private async Task Search(object query)
        {
            string queryString = query as string;

            SearchQuery = queryString;
            if (!string.IsNullOrEmpty(queryString))
            {
                var request = new PlaylistSearchRequest()
                {
                    Name = queryString
                };

                var artistsList = await _playlistService.Get <List <Model.Playlist> >(request);

                PlaylistsList.Clear();
                foreach (var Item in artistsList)
                {
                    PlaylistsList.Add(Item);
                }
            }
        }
        public async Task Init(PlaylistSearchRequest request = null)
        {
            PlaylistsList.Clear();
            try
            {
                if (request == null)
                {
                    request = new PlaylistSearchRequest()
                    {
                        UserID = SignedInUserHelper.User.ID
                    };
                }

                var playlists = await _service.Get <List <Model.Playlist> >(request);

                foreach (var playlist in playlists)
                {
                    PlaylistsList.Add(playlist);
                }
            }
            catch
            {
            }
        }