public async static Task <PostResult> PostNewsVoteAsync(VoteNews voteNews) { try { string data = JsonSerializeHelper.Serialize(voteNews); string json = await HttpHelper.Post(WcfApiUrlConstants.VoteNews, data, CacheManager.LoginUserInfo.Cookies); PostResult response = JsonSerializeHelper.Deserialize <PostResult>(json); return(response); } catch (Exception exception) { System.Diagnostics.Debug.WriteLine(exception.Message); return(new PostResult() { IsSuccess = false, Message = "提交时发送异常" }); } }
private async void LikeAppBarButton_Tapped(object sender, TappedRoutedEventArgs e) { VoteNews voteNews = new VoteNews(); voteNews.VoteType = "agree";// voteType == VoteType.Support ? "agree" : "anti"; voteNews.Id = NewsBodyViewModel.News.Id; var result = await NewsService.PostNewsVoteAsync(voteNews); if (!result.IsSuccess) { MessageDialog messageDialog = new MessageDialog(result.Message); await messageDialog.ShowAsync(); } else { NewsBodyViewModel.News.Diggs++; LikeAppBarButton.IsEnabled = false; } }