async public Task <ResponsePostComment> PostComment(RequestPostComment request) { var response = await CallService <ResponsePostComment, RequestPostComment> (Settings.URL_POST_COMMENT, HttpMethod.Post, request); return(response); }
async public void DoPostComment(){ if (string.IsNullOrEmpty (CommentText) || string.IsNullOrEmpty(CommentText.Trim()) || (!Settings.wpLoggedIn && string.IsNullOrEmpty(CommentEmail.Trim()))) { ShowErrorMessage (Settings.MSG_COMMENT_EMPTY_TEXT_ERROR); return; } if (Status == NetworkStatus.NotReachable) {//true || ShowErrorMessage (Settings.MSG_NETWORK_NOT_REACHABLE); return; } string txtCommentContent = CommentText; Debug.WriteLine ("Post comment: " + txtCommentContent); if (PostCommentPressed != null) { PostCommentPressed(this, EventArgs.Empty); } IsLoading = true; RequestPostComment req = null; if (Settings.wpLoggedIn) { req = new RequestPostComment (Post.Id, txtCommentContent); } else { req = new RequestPostComment (Post.Id, txtCommentContent,CommentName, CommentEmail); } var res = await Service.PostComment (req); try { var jo = JsonConvert.DeserializeObject<Comment>(res.Result); // var auth = new Author(); // auth.name = Settings.WP_USERNAME; // jo.Author = auth; // jo.UserId = auth.id; // jo.UserCaption = auth.slug.ToUpper()[0] + ""; jo.Content = GetCommentText(jo); if (Post.Comments == null ) Post.Comments = new List<Comment>(); Post.Comments.Add(jo); Comments.Add(jo); CommentText = string.Empty; RaisePropertyChanged(()=>CommentText); Comment_count += 1; } catch (Exception e) { Debug.WriteLine ("[CommentPage] {0}" , e); if (PostCommentPressed != null) { PostCommentPressed(this, new ErrorEventArgs("Error",e.Message,"close")); } ShowErrorMessage (Settings.MSG_NETWORK_COMMON, e); } IsLoading = false; }