private int SendComments() { if (txtcomment.Text.Trim() != "") { newcomment = new KLNewsComment(); try { newcomment.Comment = txtcomment.Text; newcomment.CreateDate = DateTime.Now; newcomment.Email = txtEmail.Text; newcomment.Name = txtFullName.Text; newcomment.UserID = currentUser.UserId; newcomment.NewsID = newsID; newcomment.Save(); KLNotify notify = new KLNotify(); KLAuthor author = new KLAuthor(news.AuthorID); notify.AuthorID = author.UserID; notify.UserName_Action = txtFullName.Text; notify.DateCreate = DateTime.Now; notify.NotifyType = "Comment"; notify.Viewed = false; News newsKL = new News(siteSettings.SiteId, news.NewsID); notify.Notify = ResourceFile.GetResourceString("CustomResources", "NotifyComment") + newsKL.Title; notify.NotifyLink = SiteRoot + "/news-detail?newsID=" + news.NewsID; notify.Save(); } catch (Exception ex) { log.Error(ex.Message); } return(newcomment.CommentID); } return(-1); }
protected void listviewComment_ItemCommand(object sender, ListViewCommandEventArgs e) { if (e.Item != null) { ListViewDataItem dataItem = (ListViewDataItem)e.Item; Label lbCommentID = (Label)e.Item.FindControl("CommentID"); try { KLNewsComment com = new KLNewsComment(int.Parse(lbCommentID.Text)); KLNews news = new KLNews(com.NewsID, 0); if (String.Equals(e.CommandName.ToLower(), "approve")) { news.CommentCount = news.CommentCount + 1; com.IsPublish = true; } else if (String.Equals(e.CommandName.ToLower(), "delete")) { int index = e.Item.DisplayIndex; listviewComment.DeleteItem(index); news.CommentCount = news.CommentCount - 1; com.IsPublish = false; com.ISDel = true; } news.Save(); com.Save(); } catch (Exception) { } } WebUtils.SetupRedirect(this, Request.RawUrl); }
protected void rptComments_ItemCommand(object source, RepeaterCommandEventArgs e) { TextBox txtsubname = (TextBox)e.Item.FindControl("txtsubname"); TextBox txtsubemail = (TextBox)e.Item.FindControl("txtsubemail"); TextBox txtsubcomment = (TextBox)e.Item.FindControl("txtsubcomment"); HiddenField commentid = (HiddenField)e.Item.FindControl("hdcommentid"); KLNewsComment subcomment = null; if (txtsubcomment.Text.Trim() != "") { subcomment = new KLNewsComment(); try { subcomment.Comment = txtsubcomment.Text; subcomment.CreateDate = DateTime.Now; subcomment.Email = txtsubemail.Text; subcomment.Name = txtsubname.Text; subcomment.UserID = currentUser.UserId; subcomment.NewsID = newsID; subcomment.CommentParentID = int.Parse(commentid.Value); subcomment.Save(); KLNotify notify = new KLNotify(); KLAuthor author = new KLAuthor(news.AuthorID); notify.AuthorID = author.UserID; notify.UserName_Action = txtsubname.Text; notify.DateCreate = DateTime.Now; notify.NotifyType = "Comment"; notify.Viewed = false; News newsKL = new News(siteSettings.SiteId, news.NewsID); notify.Notify = ResourceFile.GetResourceString("CustomResources", "NotifyComment") + newsKL.Title; notify.NotifyLink = SiteRoot + "/news-detail?newsID=" + news.NewsID; notify.Save(); divmessagecomment.InnerHtml = AlertSuccess(); } catch (Exception ex) { log.Error(ex.Message); } } }