コード例 #1
0
        public async Task CreatePlaylist(object sender, EventArgs e)
        {
#if __IOS__
            if (playListNameEntry.Text != null)
            {
                playlist             = new PlayList();
                playlist.Name        = playListNameEntry.Text;
                playlist.Description = playListDescriptionEditor.Text;
                account = _baseViewModel.GetAccountInformation();
                user    = await _baseViewModel.FindUserByIdAsync(FINDUSER, account.Properties["Id"]);

                await _playlistCreatePageViewModel.CreatePlaylist(playlist, user.Id);

                if (_playlistCreatePageViewModel.Successful)
                {
                    await Navigation.PopModalAsync();
                }
                else
                {
                    await DisplayAlert("Playlist Not Added", playlist.Name + " has not been added. Check your network connectivity!", "Ok");
                }
            }
            else
            {
                await DisplayAlert("Error", "Name cannot be empty, fill it in!", "Ok");

                playListNameEntry.Focus();
            }
#endif
#if __ANDROID__
            if (!string.IsNullOrWhiteSpace(androidPlaylistNameEntry.Text))
            {
                playlist             = new PlayList();
                playlist.Name        = androidPlaylistNameEntry.Text;
                playlist.Description = androidPlaylistDescriptionEntry.Text;
                account = _baseViewModel.GetAccountInformation();
                user    = await _baseViewModel.FindUserByIdAsync(FINDUSER, account.Properties["Id"]);

                await _playlistCreatePageViewModel.CreatePlaylist(playlist, user.Id);

                if (_playlistCreatePageViewModel.Successful)
                {
                    await Navigation.PopModalAsync();
                }
                else
                {
                    await DisplayAlert("Playlist Not Added", playlist.Name + " has not been added. Check your network connectivity!", "Ok");
                }
            }
            else
            {
                await DisplayAlert("Error", "Name cannot be empty, fill it in!", "Ok");

                androidPlaylistNameEntry.RequestFocus();
            }
#endif
        }