public void PostComment(AccessToken token, int questionId, int answerId, string content) { try { var url = string.Format(ApiUtils.QuestionsAnswerCommentsAdd, questionId, answerId.ToString()); var param = new List <OkHttpUtils.Param>() { new OkHttpUtils.Param("ParentCommentId", "0"), new OkHttpUtils.Param("Content", content), }; OkHttpUtils.Instance(token).Post(url, param, async(call, response) => { var code = response.Code(); var body = await response.Body().StringAsync(); if (code == (int)System.Net.HttpStatusCode.OK) { var user = await SQLiteUtils.Instance().QueryUser(); QuestionCommentsModel news = new QuestionCommentsModel(); news.PostUserInfo = new QuestionUserInfoModel() { UserID = user.SpaceUserId, IconName = user.Face, UCUserID = user.UserId, UserName = user.DisplayName, QScore = user.Score }; news.Content = content; news.DateAdded = DateTime.Now; news.CommentID = answerId; commentsView.PostCommentSuccess(news); } else { try { var error = JsonConvert.DeserializeObject <ErrorMessage>(body); commentsView.PostCommentFail(error.Message); } catch (Exception e) { commentsView.PostCommentFail(e.Message); } } }, (call, ex) => { commentsView.PostCommentFail(ex.Message); }); } catch (Exception e) { commentsView.PostCommentFail(e.Message); } }
public void PostCommentSuccess(QuestionCommentsModel comment) { handler.Post(() => { txtContent.Enabled = true; txtContent.Text = ""; proLoading.Visibility = ViewStates.Gone; btnComment.Visibility = ViewStates.Visible; adapter.AddData(comment); Toast.MakeText(this, Resources.GetString(Resource.String.comment_success), ToastLength.Short).Show(); }); }