Beispiel #1
0
 /// <summary>
 /// 删除回复
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="replyId"></param>
 /// <returns></returns>
 public static int DeleteReply(ForumReplyInfo replyInfo)
 {
     ForumTopicManage.UpdateReplyDeleted(replyInfo.Id);
     //更新Forums表中回复数
     ForumManage.UpdateReplies(replyInfo.ForumId, false);
     return(1);
 }
Beispiel #2
0
        /// <summary>
        /// 发表或编辑回复
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static ForumReplyInfo PostReply(ForumTopicInfo topicInfo, ForumReplyInfo replyInfo)
        {
            if (replyInfo.Id == 0)
            {
                //处理楼层
                replyInfo.Floor = topicInfo.Replies + 1;
                //添加
                replyInfo.Id = ForumTopicManage.PostReply(replyInfo);
                //Forums表
                ForumManage.UpdateReplies(replyInfo.ForumId); //回复数 + 1
                ForumManage.UpdateLastReply(replyInfo.ForumId, replyInfo.Id, replyInfo.Content, replyInfo.PostDateTime);
                ForumManage.UpdateLastPoster(replyInfo.ForumId, replyInfo.PosterId, replyInfo.Poster);

                //ForumTopics表
                ForumTopicManage.UpdateTopicRepliesCount(replyInfo.TopicId);   //回复数 + 1
                ForumTopicManage.UpdateTopicLastPoster(replyInfo.TopicId, replyInfo.PosterId, replyInfo.Poster);

                //ForumMyReply表
                ForumTopicManage.AddMyReply(replyInfo.PosterId, replyInfo.TopicId, replyInfo.Id);
            }
            else
            {
                ForumTopicManage.UpdateReply(replyInfo);
            }
            return(replyInfo);
        }
Beispiel #3
0
        public static void UpdateReply(ForumReplyInfo model)
        {
            string strSQL = "UPDATE ForumReplies SET Content = @Content WHERE Id = @Id";

            SqlParameter[] parms = ParameterHelper.GetClassSqlParameters(model);
            SQLPlus.ExecuteNonQuery(CommandType.Text, strSQL, parms);
        }
Beispiel #4
0
        public static int PostReply(ForumReplyInfo model)
        {
            string strSQL = "INSERT INTO ForumReplies(ForumId,TopicId,Content,Poster,PosterId,PostDateTime,IsDeleted,Floor) VALUES(@ForumId,@TopicId,@Content,@Poster,@PosterId,GETDATE(),0,@Floor);SELECT @@IDENTITY; ";

            SqlParameter[] parms = ParameterHelper.GetClassSqlParameters(model);
            return(Convert.ToInt32(SQLPlus.ExecuteScalar(CommandType.Text, strSQL, parms)));
        }
Beispiel #5
0
        private static ForumReplyInfo GetReplyInfo(DataRow dr)
        {
            ForumReplyInfo model = new ForumReplyInfo();

            ReflectionHelper.Fill(dr, model);
            return(model);
        }
Beispiel #6
0
        public static IPageOfList <ForumReplyInfo> ReplyList(ForumSearchSetting settings)
        {
            FastPaging fp = new FastPaging();

            fp.PageIndex   = settings.PageIndex;
            fp.PageSize    = settings.PageSize;
            fp.TableName   = "ForumReplies";
            fp.TableReName = "p";
            fp.PrimaryKey  = "ID";
            fp.QueryFields = "p.*";

            StringBuilder sbCondition = new StringBuilder();

            sbCondition.AppendFormat("  TopicId = @TopicId ");
            if (!settings.ShowDeleted)
            {
                sbCondition.Append("    AND IsDeleted = 0 ");
            }
            fp.Condition   = sbCondition.ToString();
            fp.OverOrderBy = "PostDateTime ASC";

            SqlParameter[] parms =
            {
                new SqlParameter("@TopicId", SqlDbType.Int),
            };
            parms[0].Value = settings.TopicId;

            IList <ForumReplyInfo> list  = new List <ForumReplyInfo>();
            ForumReplyInfo         model = null;
            DataTable dt = Goodspeed.Library.Data.SQLPlus.ExecuteDataTable(CommandType.Text, fp.Build2005(), parms);

            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    model = GetReplyInfo(dr);
                    if (model != null)
                    {
                        list.Add(model);
                    }
                }
            }
            int count = ReplyListCount(settings);

            return(new PageOfList <ForumReplyInfo>(list, settings.PageIndex, settings.PageSize, count));
        }
Beispiel #7
0
        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)
            });
        }