public ActionResult ShowCatalog(int?id) { int forumId = id.HasValue ? Convert.ToInt32(id.Value) : 0; var forumInfo = ForumService.Get(forumId); if (forumInfo.Id == 0) { return(new TipView() { Msg = ErrorMsg.CATALOGNOTEXISTS }); } var userInfo = UserService.Get(User.Identity.Name); //检查用户是否查看的权限 //获取通过审核的用户,只有审核通过的用户才能查看论坛 if (!CheckApplyUserAuth(userInfo.Id, forumInfo.GroupId)) { return(new TipView() { Msg = ErrorMsg.APPLYNOTPASS }); } int pageIndex = CECRequest.GetQueryInt("page", 1); var topicList = ForumTopicService.TopicList(new ForumSearchSetting() { ForumId = forumInfo.Id, PageIndex = pageIndex }); ViewBag.TopicList = topicList; //是否是版主 ViewBag.IsModerator = ForumService.IsModerator(userInfo.Id, forumId); //版主列表 var moderatorList = ForumService.GetModerators(forumId); if (moderatorList.Count > 0) { ViewBag.ModeratorList = moderatorList.Select(p => p.UserName).Aggregate((a, b) => a + "," + b); } else { ViewBag.ModeratorList = "*空缺*"; } return(View(forumInfo)); }
public ForumController() { topicService = new ForumTopicService(); postService = new ForumPostService(); boardService = new ForumBoardService(); }
public ActionResult ReplyThread(FormCollection fc) { int forumId = CECRequest.GetFormInt("catalogId", 0); int topicId = CECRequest.GetFormInt("threadId", 0); var forumInfo = ForumService.Get(forumId); //检查用户是否查看的权限 //获取通过审核的用户,只有审核通过的用户才能查看论坛 var userInfo = UserService.Get(User.Identity.Name); if (!CheckApplyUserAuth(userInfo.Id, forumInfo.GroupId)) { return(new TipView() { Msg = ErrorMsg.APPLYNOTPASS }); } //判断主题是否存在 var topicInfo = ForumTopicService.Get(topicId); string threadUrlFormat = "/thread/{0}.html{1}"; if (topicInfo.Id == 0 || topicInfo.ForumId != forumId || topicInfo.IsDeleted) { return(new TipView() { Msg = ErrorMsg.THREADNOTEXISTS }); } #region == 发表回帖 == //判断提交类型 if (CECRequest.GetFormString("event_submit_do_publish") == "anything") { string replyContent = fc["txtReplyContent"]; //判断回复内容是否为空 if (string.IsNullOrEmpty(replyContent)) { return(new TipView() { Msg = "请输入回复内容", Url = String.Format(threadUrlFormat, topicInfo.Id, string.Empty) }); } //回复 ForumReplyInfo replyInfo = new ForumReplyInfo(); replyInfo.Content = replyContent; replyInfo.ForumId = topicInfo.ForumId; replyInfo.TopicId = topicInfo.Id; replyInfo.Poster = userInfo.UserName; replyInfo.PosterId = userInfo.Id; replyInfo = ForumTopicService.PostReply(topicInfo, replyInfo); return(new TipView() { Msg = ErrorMsg.POSTREPLYSUCCESS, Url = String.Format(threadUrlFormat, topicInfo.Id, String.Format("#reply{0}", replyInfo.Id)), Success = true }); } #endregion #region == 删除回帖 == if (CECRequest.GetFormString("event_submit_do_delete") == "anything") { int replyId = CECRequest.GetFormInt("replyId", 0); var replyInfo = ForumTopicService.GetReplyInfo(replyId); if (replyInfo.Id == 0 || replyInfo.IsDeleted || topicInfo.Id != replyInfo.TopicId || replyInfo.ForumId != forumId) { return(new TipView() { Msg = ErrorMsg.NOTNORMALOPERATE, Url = String.Format(threadUrlFormat, topicInfo.Id, string.Empty) }); } ForumTopicService.DeleteReply(replyInfo); return(new TipView() { Msg = ErrorMsg.DELETEREPLYSUCCESS, Url = String.Format(threadUrlFormat, topicInfo.Id, string.Empty), Success = true }); } #endregion return(new TipView() { Msg = ErrorMsg.NOTNORMALOPERATE, Url = String.Format(threadUrlFormat, topicInfo.Id, string.Empty) }); }
public ActionResult PulishThread(ForumTopicInfo oldModel) { #region == 发表主题 == if (CECRequest.GetFormString("event_submit_do_publish") == "anything") { //发布或编辑 var forumInfo = ForumService.Get(oldModel.ForumId); //检查用户是否查看的权限 //获取通过审核的用户,只有审核通过的用户才能查看论坛 var userInfo = UserService.Get(User.Identity.Name); if (!CheckApplyUserAuth(userInfo.Id, forumInfo.GroupId)) { return(new TipView() { Msg = ErrorMsg.APPLYNOTPASS }); } ViewBag.ForumInfo = forumInfo; //在这里多设一个 //下面更新问oldModel就会自动变成新的实体 int requestTopicId = oldModel.Id; oldModel.PosterId = userInfo.Id; oldModel.Poster = userInfo.UserName; if (string.IsNullOrEmpty(oldModel.Title)) { ModelState.AddModelError("Title", "帖子标题不能为空!"); } if (string.IsNullOrEmpty(oldModel.Content)) { ModelState.AddModelError("Content", "帖子内容不能为空!"); } if (ModelState.IsValid) { oldModel = ForumTopicService.PostTopic(oldModel); string url = String.Format("/thread/{0}.html", oldModel.Id); return(new TipView() { Msg = string.Format("{0}成功!", requestTopicId > 0 ? "编辑" : "发表"), Url = url, Success = true }); } } #endregion #region == 删除主题 == if (CECRequest.GetFormString("event_submit_do_delete") == "anything") { //删除主题 int forumId = CECRequest.GetFormInt("catalogId", 0); int topicId = CECRequest.GetFormInt("threadId", 0); string returnUrl = string.Format("/catalog/{0}.html", forumId); var forumInfo = ForumService.Get(forumId); //检查用户是否查看的权限 //获取通过审核的用户,只有审核通过的用户才能查看论坛 var userInfo = UserService.Get(User.Identity.Name); if (!CheckApplyUserAuth(userInfo.Id, forumInfo.GroupId)) { return(new TipView() { Msg = ErrorMsg.APPLYNOTPASS }); } var topicInfo = ForumTopicService.Get(topicId); if (topicInfo.Id > 0 && topicInfo.ForumId == forumId && !topicInfo.IsDeleted) { //执行删除操作 ForumTopicService.DeleteTopic(topicInfo); return(new TipView() { Msg = ErrorMsg.DELETETHREADSUCCESS, Success = true, Url = returnUrl }); } return(new TipView() { Msg = ErrorMsg.NOTNORMALOPERATE, Url = returnUrl }); } #endregion return(View(oldModel)); }
public SecurityController() { boardService = new ForumBoardService(); topicService = new ForumTopicService(); postService = new ForumPostService(); }
public TagController() { boardService = new ForumBoardService(); topicService = new ForumTopicService(); }
public TopController() { topicService = new ForumTopicService(); postService = new ForumPostService(); }
public override List <ForumTopic> GetNewPosts() { IForumTopicService topicService = new ForumTopicService(); return(topicService.GetByApp(ctx.app.Id, 21)); }