public async Task <bool> DeleteCommentAsync(int id) { var newsComments = NewsComments.Where(n => n.CommentID == id).FirstOrDefault(); var result = await StoreManager.NewsDetailsService.DeleteCommentAsync(newsComments.CommentID); if (result.Success) { var index = NewsComments.IndexOf(newsComments); NewsComments.RemoveAt(index); if (NewsComments.Count == 0) { LoadStatus = LoadMoreStatus.StausNodata; } NewsDetails.CommentDisplay = (news.CommentCount = news.CommentCount - 1).ToString(); } else { Crashes.TrackError(new Exception() { Source = result.Message }); Toast.SendToast("删除失败"); } return(result.Success); }
public void AddComment(NewsComments comment) { var book = NewsComments.Where(b => b.CommentID == comment.CommentID).FirstOrDefault(); if (book == null) { NewsComments.Add(comment); NewsDetails.CommentDisplay = (news.CommentCount = news.CommentCount + 1).ToString(); } else { var index = NewsComments.IndexOf(book); NewsComments[index] = comment; } if (LoadStatus == LoadMoreStatus.StausNodata) { LoadStatus = LoadMoreStatus.StausEnd; } }