[ValidateInput(false)]  //允许特殊字符提交/
        public ActionResult Add(string title, int classify, string content)
        {
            try
            {
                Topicforum topicForum = new Topicforum();
                User       user       = new User();
                string     userName   = CurrentUser.Username;
                int        userId     = CurrentUser.Id;
                if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(userId.ToString()))
                {
                    topicForum.Title              = title;
                    topicForum.Content            = content;
                    topicForum.Top                = false;
                    topicForum.Time               = DateTime.Now;
                    topicForum.LastReply          = DateTime.Now;
                    topicForum.UserId             = userId;
                    topicForum.Reward             = 0;
                    topicForum.IsShow             = true;
                    topicForum.IsClose            = false;
                    topicForum.IsOfficeIdentified = false;
                    topicForum.PlateforumId       = classify;


                    bllSession.ITopicforumBLL.Insert(topicForum);
                    log.Info(new LogContent(userName + "用户发布了新的帖子", LogType.记录.ToString(), HttpHelper.GetIPAddress()));
                }
            }
            catch (Exception ex)
            {
                log.Error(new LogContent("用户发布主题出错", LogType.异常.ToString(), HttpHelper.GetIPAddress()));
                ModelState.AddModelError("", "用户发布主题出错!");
            }
            return(RedirectToAction("Index", "Forum"));
        }
Exemple #2
0
 public ActionResult TopicAdd(Topicforum model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             model.Browses = 0;
             model.Reward  = 1;
             model.Time    = DateTime.Now;
             model.UserId  = CurrentUser.Id;
             model.Report  = 0;
             bllSession.ITopicforumBLL.Insert(model);
             log.Info(new LogContent(CurrentUser.Username + ":增加了板块:" + model.PlateforumId + "的主题:" + model.Title, LogType.记录.ToString(), HttpHelper.GetIPAddress()));
             return(Redirect("/Admin/Forum/TopicManage/" + model.PlateforumId));
         }
         catch (Exception ex)
         {
             log.Error(new LogContent(CurrentUser.Username + ":增加了板块:" + model.PlateforumId + "的主题出错", LogType.异常.ToString(), HttpHelper.GetIPAddress()), ex);
         }
     }
     else
     {
         ModelState.AddModelError("", "数据填写错误");
     }
     return(View());
 }
Exemple #3
0
 public ActionResult TopicEdit(Topicforum model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             var topic = bllSession.ITopicforumBLL.GetEntity(model.Id);
             topic.Title              = model.Title;
             topic.Content            = model.Content;
             topic.IsShow             = model.IsShow;
             topic.Top                = model.Top;
             topic.IsClose            = model.IsClose;
             topic.IsOfficeIdentified = model.IsOfficeIdentified;
             bllSession.ITopicforumBLL.Update(topic);
             log.Info(new LogContent(CurrentUser.Username + ":修改板块:" + topic.PlateforumId + "的主题:" + model.Title, LogType.记录.ToString(), HttpHelper.GetIPAddress()));
             return(Redirect("/Admin/Forum/TopicManage/" + topic.PlateforumId));
         }
         catch (Exception ex)
         {
             log.Error(new LogContent(CurrentUser.Username + ":修改了板块:" + model.PlateforumId + "的主题出错", LogType.异常.ToString(), HttpHelper.GetIPAddress()), ex);
             ModelState.AddModelError("", "修改板块出错,请重试!");
         }
     }
     else
     {
         ModelState.AddModelError("", "数据填写错误");
     }
     return(View());
 }
Exemple #4
0
        public vForum(Topicforum model)
        {
            Markdown mark = new Markdown();

            this.Id                 = model.Id;
            this.Title              = model.Title;
            this.Content            = mark.Transform(model.Content);
            this.Top                = model.Top;
            this.Time               = model.Time;
            this.LastReply          = model.LastReply;
            this.UserId             = model.UserId;
            this.Reward             = model.Reward;
            this.Browses            = model.Browses;
            this.Report             = model.Report;
            this.IsShow             = model.IsShow;
            this.IsClose            = model.IsClose;
            this.IsOfficeIdentified = model.IsOfficeIdentified;
        }
        public ActionResult Show(int id)
        {
            Topicforum topicforum = new Topicforum();

            topicforum         = bllSession.ITopicforumBLL.GetEntity(id);
            topicforum.Browses = topicforum.Browses + 1;
            bllSession.ITopicforumBLL.Update(topicforum);

            if (!Request.IsAuthenticated)
            {
                log.Info(new LogContent("游客访问了帖子", LogType.记录.ToString(), HttpHelper.GetIPAddress()));
            }
            else
            {
                string userName = CurrentUser.Username;
                log.Info(new LogContent(userName + "用户访问了帖子", LogType.记录.ToString(), HttpHelper.GetIPAddress()));
            }
            return(View(topicforum));
        }