protected String GetCommentReplyHtml(Comment comment, RepeaterItem item) { CommentReplyManager manager = new CommentReplyManager(); IList<CommentReply> replyes = manager.GetCommentReplyByCommentID(comment.ID); HtmlGenericControl divReply = item.FindControl("divReply") as HtmlGenericControl; HyperLink hplReply = item.FindControl("hplReply") as HyperLink; if (replyes != null && replyes.Count > 0) { ///Show the Reply Link divReply.Visible = true; hplReply.Attributes["onclick"] = String.Format("ShowPopupForCommentReply({0}, this);", comment.ID); UserManager userManager = new UserManager(); StringBuilder sb = new StringBuilder(10); #region Expand Collapse Implementation //sb.Append("Comment Replyes:"); //foreach (CommentReply reply in replyes) //{ // PlanningPrepUser user = userManager.Get(reply.UserID); // sb.Append("<div style='margin-top:10px;'>"); // sb.Append("<div class='ExamTitle' onclick='ToggleCollapse(this)' style='cursor:pointer'>"); // sb.AppendFormat("<img class='clickableimage' src='/Images/plus.gif' alt='Expand' title='Expand'/> {0}", user.Username); // sb.Append("</div>"); // sb.AppendFormat("<div class='replymessage' style='display:none;'>{0}</div>", AppUtil.FormatText(reply.Message)); // sb.Append("</div>"); //} #endregion for(int i=0; i<replyes.Count; i++) { CommentReply reply = replyes[i]; PlanningPrepUser user = userManager.Get(reply.UserID); if (i == 0) sb.Append("<div class='replymessagecontainer' style='margin-top:10px;'>"); else sb.Append("<div class='replymessagecontainer'>"); sb.AppendFormat("<div class='replymessageheading'>Reply of <b>{0}</b></div>", AppUtil.Encode(string.Format("{0} {1}",user.FirstName,user.LastName))); sb.Append(string.Format("\"{0}\"", AppUtil.FormatText(reply.Message))); sb.Append("</div>"); } return sb.ToString(); } else { ///Show the Reply Link if this commment is not the users own comment if (comment.UserID != _LoggedInUser.Author_ID) { divReply.Visible = true; hplReply.Attributes["onclick"] = String.Format("ShowPopupForCommentReply({0}, this);", comment.ID); } } if (_LoggedInUser.Author_ID == 0) divReply.Visible = false; return String.Empty; }
/// <summary> /// 回复控制器 /// </summary> public CommentReplyController(CommentReplyManager commentReplyManager, IMapper mapper) { _commentReplyManager = commentReplyManager ?? throw new ArgumentNullException(nameof(commentReplyManager)); _mapper = mapper; }
public long SaveCommentReply(App.Models.Comments.CommentReply commentReply) { if (commentReply != null) { CommentReplyManager manager = new CommentReplyManager(); commentReply.Created = DateTime.Now; manager.SaveOrUpdate(commentReply); return commentReply.Id; } return -1; }