private async void PostCommentButton_Tapped(object sender, TappedRoutedEventArgs e) { string body; CommentTextBox.Document.GetText(Windows.UI.Text.TextGetOptions.None, out body); if (!AuthenticationService.IsLogin) { MessageDialog messageDialog = new MessageDialog("请先登录"); await messageDialog.ShowAsync(); AuthenticationService.RedictLoginPage(); return; } PostNewsComment postNewsComment = new PostNewsComment(); postNewsComment.ContentId = this.NewsCommentViewModel.News.Id; postNewsComment.Content = body; postNewsComment.StrComment = ""; postNewsComment.ParentCommentId = this.NewsCommentViewModel.News.Id; postNewsComment.Title = this.NewsCommentViewModel.News.Title; PostResult postBlogCommentResponse = await NewsService.PostCommentAsync(postNewsComment); if (!postBlogCommentResponse.IsSuccess) { MessageDialog messageDialog = new MessageDialog(postBlogCommentResponse.Message); await messageDialog.ShowAsync(); //其他异常则不处理 if (postBlogCommentResponse.Message.Contains("登录")) { AuthenticationService.RedictLoginPage(); } return; } else { this.NewsCommentViewModel.Refresh(); } }
public async static Task <PostResult> PostCommentAsync(PostNewsComment postNewsComment) { try { string data = JsonSerializeHelper.Serialize(postNewsComment); string json = await HttpHelper.Post(WcfApiUrlConstants.PostBlogComment, 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 = "提交时发送异常" }); } }