public async Task <List <AnswersComments> > ReloadCommentsAsync() { LoadStatus = LoadMoreStatus.StausLoading; var result = await StoreManager.AnswersDetailsService.GetCommentAsync(answers.AnswerID); if (result.Success) { var comments = JsonConvert.DeserializeObject <List <AnswersComments> >(result.Message.ToString()); if (comments.Count > 0) { if (AnswersComments.Count > 0) { AnswersComments.Clear(); } AnswersComments.AddRange(comments); LoadStatus = LoadMoreStatus.StausEnd; } else { LoadStatus = LoadMoreStatus.StausNodata; } CanLoadMore = false; } else { Crashes.TrackError(new Exception() { Source = result.Message }); LoadStatus = LoadMoreStatus.StausError; } return(AnswersComments); }
public async Task <bool> DeleteAnswersCommentsAsync(int id) { var answersComments = AnswersComments.Where(n => n.CommentID == id).FirstOrDefault(); var result = await StoreManager.AnswersDetailsService.DeleteCommentAsync(answers.Qid, answers.AnswerID, answersComments.CommentID); if (result.Success) { var index = AnswersComments.IndexOf(answersComments); AnswersComments.RemoveAt(index); if (AnswersComments.Count == 0) { LoadStatus = LoadMoreStatus.StausNodata; } AnswersDetails.CommentDisplay = (answers.CommentCounts = answers.CommentCounts - 1).ToString(); } else { Crashes.TrackError(new Exception() { Source = result.Message }); Toast.SendToast("删除失败"); } return(result.Success); }
async void OnResult(AnswersComments result) { if (result != null) { ViewModel.EditComment(result); await formsWebView.InjectJavascriptAsync("updateComment(" + JsonConvert.SerializeObject(result) + ");"); } }
public AnswersCommentPopupPage(QuestionsAnswers answers, Action <AnswersComments> result, AnswersComments answersComment = null) { this.answers = answers; this.result = result; this.answersComment = answersComment; InitializeComponent(); BindingContext = new AnswersDetailsViewModel(answers); if (answersComment != null) { this.Comment.Text = answersComment.Content; } this.Comment.Focus(); ViewModel.IsBusy = false; }
public AnswersCommentPopupPage(QuestionsAnswers answers, Action <AnswersComments> result, AnswersComments answersComment = null) { InitializeComponent(); Xamarin.Forms.PlatformConfiguration.iOSSpecific.Page.SetUseSafeArea(this, true); this.answers = answers; this.result = result; this.answersComment = answersComment; BindingContext = new AnswersDetailsViewModel(answers); if (answersComment != null) { this.Comment.Text = answersComment.Content; } this.Comment.Focus(); ViewModel.IsBusy = false; }
public void EditComment(AnswersComments comment) { var book = AnswersComments.Where(b => b.CommentID == comment.CommentID).FirstOrDefault(); if (book == null) { AnswersComments.Add(comment); AnswersDetails.CommentDisplay = (answers.CommentCounts = answers.CommentCounts + 1).ToString(); } else { var index = AnswersComments.IndexOf(book); AnswersComments[index] = comment; } if (LoadStatus == LoadMoreStatus.StausNodata) { LoadStatus = LoadMoreStatus.StausEnd; } }
private void ClosePopupPage(string result) { if (result != null) { if (answersComment == null) { answersComment = new AnswersComments(); answersComment.PostUserInfo = new QuestionUserInfo() { UserID = UserSettings.Current.SpaceUserId, IconName = UserSettings.Current.Avatar, UCUserID = UserSettings.Current.UserId, UserName = UserSettings.Current.DisplayName, QScore = UserSettings.Current.Score }; } answersComment.Content = result; answersComment.DateAdded = DateTime.Now; this.result.Invoke(answersComment); } PopupNavigation.PopAsync(); }