public void comment(HttpContext context) { string user_id = TravelAgent.Tool.CookieHelper.GetCookieValue("uid"); string msg = ""; if (string.Empty == user_id) { msg = "{\"result\":\"false\",\"reason\":\"needlogin\"}"; context.Response.Write(msg); return; } string contents = context.Request["contents"]; int comment_type = Convert.ToInt32(context.Request["comment_type"]); int comment_rel_id = Convert.ToInt32(context.Request["comment_rel_id"]); Club user = club.GetModel(Convert.ToInt32(user_id)); TourComment comm = new TourComment(); comm.contents = contents; comm.comment_type = comment_type; comm.comment_rel_id = comment_rel_id; comm.user_id = user.id; comm.nickname = user.clubMobile; comm.create_time = DateTime.Now; comments.Add(comm); //更新评论数 TourGuide tg = guide.GetModel(comment_rel_id); List <TourComment> tclist = comments.GetList(comment_rel_id); tg.commentcount = (tclist.Count); guide.Update(tg); msg = "{\"result\":\"true\",\"reason\":\"true\"}"; context.Response.Write(msg); }
protected void buttonSubmit_Click(object sender, EventArgs e) { // Nếu đã đánh dấu I agree, có nội dung comment, có tên author, email hoặc đã đăng nhập if (chkAgree.Checked && !string.IsNullOrEmpty(textBoxComment.Text) && ((!string.IsNullOrEmpty(textBoxAuthor.Text) && !string.IsNullOrEmpty(textBoxEmail.Text)) || PageEngine.User.Identity is User)) { if (textBoxVerifierCode.Text == imageVerifier.Text) { TourComment comment = new TourComment(); comment.Deleted = false; if (Page.User.Identity is User) { comment.Author = ((User)Page.User.Identity).FullName; comment.AuthorId = ((User)Page.User.Identity); comment.Email = ((User)Page.User.Identity).Email; } else { comment.Author = textBoxAuthor.Text; comment.AuthorId = null; comment.Email = textBoxEmail.Text; } comment.DateCreated = DateTime.Now; comment.DateModified = DateTime.Now; comment.Comment = textBoxComment.Text; comment.Status = 0; comment.Tour = _tour; comment.IP = Request.UserHostAddress; chkAgree.Checked = false; textBoxComment.Text = string.Empty; Module.SaveOrUpdate(comment); rptReviews.DataSource = _tour.Comments; rptReviews.DataBind(); imageVerifier.Refresh(); } else { labelFailedVerified.Visible = true; } } }
public async Task <ActionResult <TourComment> > AddTourComment(int tourId, TourComment tourComment) { tourComment.TourId = tourId; _context.TourComments.Add(tourComment); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (TourCommentExists(tourComment.Id)) { return(Conflict()); } else { throw; } } return(Ok()); }
private void CommentList(List <TourComment> clist) { StringBuilder sb = new StringBuilder(); sb.Append("<div class=\"comment_list\">"); for (int i = 0; i < clist.Count; i++) { TourComment tc = clist[i]; sb.Append("<div class=\"comment_content\">"); sb.Append(" <div class=\"comment_info\">"); sb.Append(" <div class=\"floor_info\">"); sb.Append(" <p class=\"floor_info_p\">"); sb.Append(" <a href=\"#\">" + tc.nickname + "</a>"); sb.Append("</p>"); sb.Append("<div class=\"floor_content\">"); sb.Append(" <div class=\"inner_floor_content\">"); sb.Append(" <blockquote>"); sb.Append(" <p>" + tc.contents + "</p>"); sb.Append("</blockquote>"); sb.Append("<div class=\"quote_info\">"); sb.Append("<span class=\"quote_time\">发表于 " + tc.create_time.ToString("yyyy-MM-dd HH:mm:ss") + "</span>"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("</div>"); sb.Append(" <div class=\"blank15\"></div>"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div class=\"comment_portait\">"); sb.Append("<a href=\"#\"><img class=\"GUID\" uid=\"11\" src=\"../member/images/clubpic.gif\" style=\"width:50;height:50;\"></a>"); sb.Append("</div>"); sb.Append("</div>"); //sb.Append(""); //sb.Append("</div>"); } sb.Append("</div>"); show_comment.InnerHtml = sb.ToString(); }
protected void rptReviews_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.DataItem is TourComment) { TourComment comment = (TourComment)e.Item.DataItem; Label labelAuthor = e.Item.FindControl("labelAuthor") as Label; if (labelAuthor != null) { if (comment.AuthorId != null) { comment.Author = comment.AuthorId.FullName; } labelAuthor.Text = string.Format("{0:F} by {1}", comment.DateCreated, comment.Author); } Label labelContent = e.Item.FindControl("labelContent") as Label; if (labelContent != null) { labelContent.Text = string.Format("{0}", comment.Comment); } } }
protected void rptComments_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.DataItem is TourComment) { TourComment comment = (TourComment)e.Item.DataItem; HyperLink labelUserName = e.Item.FindControl("labelUserName") as HyperLink; if (labelUserName != null) { if (comment.AuthorId != null) { labelUserName.Text = comment.AuthorId.UserName; labelUserName.NavigateUrl = string.Format("AdminComments.aspx?NodeId={0}&SectionId={1}&UserId={2}", Node.Id, Section.Id, comment.AuthorId.Id); } else { labelUserName.Text = "Anonymous"; labelUserName.NavigateUrl = string.Format("AdminComments.aspx?NodeId={0}&SectionId={1}&UserId={2}", Node.Id, Section.Id, 0); } } Label labelFullName = e.Item.FindControl("labelFullName") as Label; if (labelFullName != null) { if (comment.AuthorId != null) { labelFullName.Text = comment.AuthorId.FullName; } else { labelFullName.Text = comment.Author; } } HyperLink labelEmail = e.Item.FindControl("labelEmail") as HyperLink; if (labelEmail != null) { if (comment.AuthorId != null) { labelEmail.Text = comment.AuthorId.Email; } else { labelEmail.Text = comment.Email; } labelEmail.NavigateUrl = "mailto:" + comment.Email; } HyperLink labelIP = e.Item.FindControl("labelIP") as HyperLink; if (labelIP != null) { labelIP.Text = comment.IP; labelIP.NavigateUrl = string.Format("AdminComments.aspx?NodeId={0}&SectionId={1}&IP={2}", Node.Id, Section.Id, comment.IP); } HyperLink labelLandscape = e.Item.FindControl("labelLandscape") as HyperLink; if (labelLandscape != null) { labelLandscape.Text = comment.Tour.Name; labelLandscape.NavigateUrl = string.Format("AdminComments.aspx?NodeId={0}&SectionId={1}&TourId={2}", Node.Id, Section.Id, comment.Tour.Id); } HtmlGenericControl labelContent = e.Item.FindControl("labelContent") as HtmlGenericControl; if (labelContent != null) { labelContent.Attributes.Add("class", "hover_content"); labelContent.InnerHtml = comment.Comment; } Label labelOnHover = e.Item.FindControl("labelOnHover") as Label; if (labelOnHover != null && labelContent != null) { labelOnHover.Text = "View content"; labelOnHover.Attributes.Add("onmouseover", "at_show_if('" + labelOnHover.ClientID + "','" + labelContent.ClientID + "');"); } HyperLink labelPosted = e.Item.FindControl("labelPosted") as HyperLink; if (labelPosted != null) { labelPosted.Text = comment.DateCreated.ToString("dd/MM/yyyy"); labelPosted.NavigateUrl = string.Format("AdminComments.aspx?NodeId={0}&SectionId={1}&Posted={2}", Node.Id, Section.Id, labelPosted.Text); } } }
public void SaveOrUpdate(TourComment comment) { _commonDao.SaveOrUpdateObject(comment); }
public void Delete(TourComment comment) { _commonDao.DeleteObject(comment); }