public OperationResult ReleaseFroumComment(ForumCommentView model) { if (Session["SystemUser"] == "" || Session["SystemUser"] == null) { return(new OperationResult(OperationResultType.PurviewLack, "登陆后,方可发表评论!")); } PublicHelper.CheckArgument(model, "model"); ForumComment releaseForumComment = new ForumComment { CommentContent = model.CommentContent, SystemUserID = ((SystemUser)Session["SystemUser"]).Id, UserName = ((SystemUser)Session["SystemUser"]).UserName, HeadImage = ((SystemUser)Session["SystemUser"]).HeadImage, ForumID = model.ForumID, CommentUserID = model.CommentUserID, CommentUserName = model.CommentUserName, ParentCommentID = model.ParentCommentID }; OperationResult result = base.ReleaseForumComment(releaseForumComment); return(result); }
public List <ForumCommentView> GetCategoryList(int Id, int?id) { int pageIndex = id ?? 1; const int pageSize = 20; PropertySortCondition[] sortConditions = new[] { new PropertySortCondition("Id") }; int total; List <ForumCommentView> commentModel = new List <ForumCommentView>(); var commentList = ForumCommentSiteContract.ForumComments.Where <ForumComment, int>(m => m.ForumID == idValue && m.ParentCommentID == Id, pageIndex, pageSize, out total, sortConditions).ToList(); if (commentList.Count > 0) { foreach (var m in commentList) { ForumCommentView ViewModel = new ForumCommentView { CommentContent = m.CommentContent, CommentUserID = m.CommentUserID, CommentUserName = m.CommentUserName, ForumCommentID = m.Id, UserName = m.UserName, ForumID = m.ForumID, HeadImage = m.HeadImage, AndDate = m.AddDate, ParentCommentID = m.ParentCommentID, SystemUserID = m.SystemUserID, ChildrenForumComment = new List <ForumCommentView>() }; List <ForumCommentView> tempList = GetCategoryList(m.Id, id); if (tempList.Count > 0) { ViewModel.ChildrenForumComment = tempList; } commentModel.Add(ViewModel); } } PagedList <ForumCommentView> model = new PagedList <ForumCommentView>(commentModel, pageIndex, pageSize, total); return(model); }
public ActionResult ReleaseForumComment(ForumCommentView model) { try { idValue = int.Parse(Request["ForumID"]); OperationResult result = ForumCommentSiteContract.ReleaseFroumComment(model); string msg = result.Message ?? result.ResultType.ToDescription(); if (result.ResultType == OperationResultType.Success) { return(Redirect("ForumDetail?ForumID=" + idValue + "")); } ModelState.AddModelError("", msg); return(Redirect("ForumDetail?ForumID=" + idValue + "")); } catch (Exception e) { ModelState.AddModelError("", e.Message); return(Redirect("ForumDetail?ForumID=" + idValue + "")); } }