コード例 #1
0
ファイル: MyMusicViewModel.cs プロジェクト: Haz3/Soonzik
 private void CreatePlaylistExecute()
 {
     var playlist = new Playlist
     {
         name = "MyPlaylist",
         user = Singleton.Singleton.Instance().CurrentUser,
         musics = new List<Music> {MusicForPlaylist}
     };
     if (MusicForPlaylist != null)
     {
         var post = new HttpRequestPost();
         try
         {
             ValidateKey.GetValideKey();
             var test = post.SavePlaylist(playlist, Singleton.Singleton.Instance().SecureKey,
                 Singleton.Singleton.Instance().CurrentUser);
             test.ContinueWith(delegate(Task<string> tmp)
             {
                 var res = tmp.Result;
                 if (res != null)
                 {
                     CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                         () =>
                         {
                             var stringJson = JObject.Parse(res).SelectToken("content").ToString();
                             var playList =
                                 (Playlist)
                                     JsonConvert.DeserializeObject(stringJson, new Playlist().GetType());
                             try
                             {
                                 ValidateKey.GetValideKey();
                                 var up = post.UpdatePlaylist(playList, MusicForPlaylist,
                                     Singleton.Singleton.Instance().SecureKey,
                                     Singleton.Singleton.Instance().CurrentUser);
                                 up.ContinueWith(delegate(Task<string> tmp2)
                                 {
                                     var res2 = tmp2.Result;
                                     if (res2 != null)
                                     {
                                         CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
                                             CoreDispatcherPriority.Normal, RefreshPlaylist);
                                     }
                                 });
                             }
                             catch (Exception)
                             {
                                 new MessageDialog(loader.GetString("ErrorUpdatePlaylist")).ShowAsync();
                             }
                         });
                 }
             });
         }
         catch (Exception)
         {
             new MessageDialog(loader.GetString("ErrorUpdatePlaylist")).ShowAsync();
         }
     }
     else
     {
         new MessageDialog(loader.GetString("ErrorNoMusic")).ShowAsync();
     }
 }
コード例 #2
0
ファイル: MyMusicViewModel.cs プロジェクト: Haz3/Soonzik
        private void PlaylistTappedExecute()
        {
            if (MusicForPlaylist == null && !_delete)
            {
                PlaylistViewModel.PlaylistTmp = SelectedPlaylist;
                GlobalMenuControl.SetChildren(new PlaylistView());
            }
            else if (!_delete)
            {
                new MessageDialog(loader.GetString("AddPlaylist")).ShowAsync();

                SelectedPlaylist.musics.Add(MusicForPlaylist);

                var request = new HttpRequestGet();
                var post = new HttpRequestPost();
                try
                {
                    ValidateKey.GetValideKey();
                    var test = post.UpdatePlaylist(SelectedPlaylist, MusicForPlaylist,
                        Singleton.Singleton.Instance().SecureKey,
                        Singleton.Singleton.Instance().CurrentUser);
                    test.ContinueWith(delegate(Task<string> tmp)
                    {
                        var res = tmp.Result;
                        if (res != null)
                        {
                            CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                RefreshPlaylist);
                        }
                    });
                }
                catch (Exception)
                {
                    new MessageDialog(loader.GetString("ErrorUpdatePlaylist")).ShowAsync();
                }
            }
            else
            {
                _delete = false;
            }
        }