public static void CreateComment(CommentPoster comment) { comment.Comment.Id = Logical.Setter(comment.Comment.Id); contextLite.Comment.Insert(comment.Comment); //context.Comment.InsertOne(comment.Comment); }
/// <summary> /// Fires when the user clicks on Add a Comment, on the status page. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void CommentButton_Click(object sender, RoutedEventArgs e) { //The logged in user can make a comment by simply clicking this button. Button btn = sender as Button; Datum datum = (Datum)btn.DataContext; if (datum != null) { commentPoster = new CommentPoster(); PostWindow postWindow = new PostWindow(); postWindow.titleText.Text = "Add a comment"; postWindow.theStatusPostControl.Visibility = Visibility.Visible; postWindow.theLinksControl.Visibility = Visibility.Hidden; postWindow.theBlogPostControl.Visibility = Visibility.Hidden; postWindow.ShowDialog(); string tkBuild = "Bearer " + Token; string comment = postWindow.theStatusPostControl.Body; loadingTextBlock.Text = "Making a comment..."; await commentPoster.MakeAComment(tkBuild, datum.id, comment); if (commentPoster.success == true) { loadingTextBlock.Text = "Commented Successfully."; Refresh(); } else { loadingTextBlock.Text = "Unable to post your comment at this time. Please try again later."; } //MessageBox.Show("Unable to comment at this time."); } }
public ActionResult <ConfessLoader> Add([FromBody] CommentPoster data) { try { bool isSafe = Logic.CheckSpamFree(data.Comment.Body.ToLower()); if (isSafe) { Store.CommentClass.CreateComment(data); Push.SendCommentNotification(data.Comment); } else { Push.NotifyOwnerOFSpam(data.Comment.Owner_Guid); } //send back the confession ConfessLoader loader = Store.ConfessClass.FetchOneConfessLoader(data.Comment.Confess_Guid, data.Comment.Owner_Guid); return(Ok(loader)); } catch (Exception ex) { return(new ConfessLoader() { }); } }
public static async Task <ConfessLoader> CreateComment(Comment comment, string confessGuid, string token, string key) { try { string url = $"comment/add"; CommentPoster poster = new CommentPoster() { Comment = comment, ConfessGuid = confessGuid, Key = key }; string content = await BaseClient.PostEntities(url, JsonConvert.SerializeObject(poster), token); ConfessLoader data = JsonConvert.DeserializeObject <ConfessLoader>(content); return(data); } catch (Exception ex) { return(null); } }
public static async Task <ConfessLoader> CreateComment(Comment comment, string confessGuid) { try { string url = $"comment/add"; CommentPoster poster = new CommentPoster() { Comment = comment, ConfessGuid = confessGuid, Key = await Logic.GetKey() }; string content = await BaseClient.PostEntities(url, JsonConvert.SerializeObject(poster)); ConfessLoader data = JsonConvert.DeserializeObject <ConfessLoader>(content); return(data); } catch (Exception ex) { Crashes.TrackError(ex, Logic.GetErrorProperties(ex)); return(null); } }
protected void Page_Load(object sender, EventArgs e) { int id = Convert.ToInt32(Request.QueryString["id"]); int channel = ContentManager.GetDbRecord(id).fk_channel_id; NavigationControl nav = new NavigationControl(); sidebar.InnerHtml = nav.GetHtml(channel); ContentPresenter cp = new ContentPresenter(id); content.InnerHtml = cp.GetHtml(); content.InnerHtml += "<p> </p>"; // 附件 if (ContentManager.GetAttachments(id).Count() > 0) { AttachmentPresenter ap = new AttachmentPresenter(id); TongJi.Web.Controls.HtmlDivision div = new TongJi.Web.Controls.HtmlDivision(); div.InnerHtml = ap.GetHtml(); content.Controls.Add(div); content.Controls.Add(new TongJi.Web.Controls.HtmlParagraph()); } // 评论 if (ContentManager.GetDbRecord(id).allow_comment) { if (ContentManager.GetComments(id).Count() > 0) { CommentPresenter presenter = new CommentPresenter(id); TongJi.Web.Controls.HtmlDivision div = new TongJi.Web.Controls.HtmlDivision(); div.InnerHtml = presenter.GetHtml(); content.Controls.Add(div); } CommentPoster poster = new CommentPoster(id); content.Controls.Add(poster.GetControl()); poster.Post += new EventHandler(poster_Post); } }
/// <summary> /// Fires when the user intends to make a comment. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void CommentButton_Click(object sender, RoutedEventArgs e) { string tkBuild = "Bearer " + Token; Button btn = sender as Button; ForumModel.Datum datum = (ForumModel.Datum)btn.DataContext; if (datum != null) { int Id = datum.id; commentPoster = new CommentPoster(); PostWindow postWindow = new PostWindow(); postWindow.theStatusPostControl.Visibility = Visibility.Visible; postWindow.theLinksControl.Visibility = Visibility.Hidden; postWindow.theBlogPostControl.Visibility = Visibility.Hidden; postWindow.ShowDialog(); string comment = postWindow.theStatusPostControl.Body; loadingTextBlock.Text = "Making a comment..."; await commentPoster.MakeAComment(tkBuild, Id, comment); if (commentPoster.success) { loadingTextBlock.Text = "Commented Successfully."; Refresh(); } else { loadingTextBlock.Text = "Unable to post your comment."; //MessageBox.Show("Unable to comment at this time."); } } }