Ejemplo n.º 1
0
        private async void btnAgree_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            Comment selectedComment = ((MenuFlyoutItem)sender).DataContext as Comment;

            if (ViewModelLocator.AppShell.UserInfo.Name == string.Empty)
            {
                selectedComment.Likes++;
                selectedComment.Voted = !selectedComment.Voted;
                return;
            }

            if (!selectedComment.Voted)
            {
                string resJosn = await WebProvider.GetInstance().SendPostRequestAsync($"http://news-at.zhihu.com/api/4/vote/comment/{selectedComment.Id}", string.Empty, WebProvider.ContentType.ContentType1);

                if (!string.IsNullOrEmpty(resJosn))
                {
                    selectedComment.Likes = (int)JsonObject.Parse(resJosn)["count"].GetNumber();
                }
            }
            else
            {
                string resJosn = await WebProvider.GetInstance().SendDeleteRequestAsync($"http://news-at.zhihu.com/api/4/vote/comment/{selectedComment.Id}");

                if (!string.IsNullOrEmpty(resJosn))
                {
                    selectedComment.Likes = (int)JsonObject.Parse(resJosn)["count"].GetNumber();
                }
            }
            selectedComment.Voted = !selectedComment.Voted;
        }
Ejemplo n.º 2
0
        private void btnReport_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            Comment selectedComment = ((MenuFlyoutItem)sender).DataContext as Comment;
            var     msgPopup        = new MessagePopupWindow("");

            msgPopup.RightClick += async(s, ea) => {
                string resJosn = await WebProvider.GetInstance().SendDeleteRequestAsync($"http://news-at.zhihu.com/api/4/report/comment/{selectedComment.Id}");
            };
            msgPopup.ShowWIndow();
        }
Ejemplo n.º 3
0
        private async void btnDelete_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            Comment selectedComment = ((MenuFlyoutItem)sender).DataContext as Comment;
            await WebProvider.GetInstance().SendDeleteRequestAsync($"http://news-at.zhihu.com/api/4/comment/{selectedComment.Id}");

            if (_viewModel.LongComments != null && _viewModel.LongComments.Contains(selectedComment))
            {
                _viewModel.LongComments.Remove(selectedComment);
            }
            if (_viewModel.ShortComments != null && _viewModel.ShortComments.Contains(selectedComment))
            {
                _viewModel.ShortComments.Remove(selectedComment);
            }
        }
Ejemplo n.º 4
0
        private async void btn_DelFav_Click(object sender, RoutedEventArgs e)
        {
            Story selectedStory = ((MenuFlyoutItem)sender).DataContext as Story;

            if (selectedStory != null)
            {
                //await CollectionDS.Instance.RemoveFav(selectedStory);
                await WebProvider.GetInstance().SendDeleteRequestAsync($"http://news-at.zhihu.com/api/4/favorite/{selectedStory.Id}");

                if (_viewModel.CollectionStories != null && _viewModel.CollectionStories.Count > 0)
                {
                    _viewModel.CollectionStories.Remove(selectedStory);
                    _viewModel.UpdateCount();
                }
                ToastPrompt.ShowToast("已成功取消收藏");
            }
        }
Ejemplo n.º 5
0
 private async void btn_newsCollection_Click(object sender, RoutedEventArgs e)
 {
     if (AppSettings.Instance.UserInfoJson == string.Empty)
     {
         await new Functions().SinaLogin();
         if (AppSettings.Instance.UserInfoJson == string.Empty)
         {
             return;
         }
     }
     if (newsContentViewModel.StoryExtra.Favorite)
     {
         await WebProvider.GetInstance().SendDeleteRequestAsync($"http://news-at.zhihu.com/api/4/favorite/{newsId}");
     }
     else
     {
         await WebProvider.GetInstance().SendPostRequestAsync($"http://news-at.zhihu.com/api/4/favorite/{newsId}", string.Empty, WebProvider.ContentType.ContentType1);
     }
     newsContentViewModel.StoryExtra.Favorite = !newsContentViewModel.StoryExtra.Favorite;
 }
Ejemplo n.º 6
0
 private async void btnPopul_Click(object sender, RoutedEventArgs e)
 {
     newsContentViewModel.StoryExtra.VoteStatus = Math.Abs(newsContentViewModel.StoryExtra.VoteStatus - 1);
     await WebProvider.GetInstance().SendPostRequestAsync($"http://news-at.zhihu.com/api/4/vote/story/{newsId}", $"data={newsContentViewModel.StoryExtra.VoteStatus}", WebProvider.ContentType.ContentType2);
 }