コード例 #1
0
        public ActionResult AddPost([Bind(Include = "Post_id,User_id,PostContent,PostTime,ForumSection_id,Post_Click,PostName")] Post post)
        {
            try
            {
                string postname = Request["post_nume"];
                var    forumid  = Convert.ToInt32(Session["Forution_id"]);
                var    fghht    = Session["Forution_id"].ToString();

                if (ModelState.IsValid)
                {
                    post.ForumSection_id = forumid;
                    post.PostName        = postname;
                    post.PostTime        = DateTime.Now;
                    post.Post_Click      = 1;
                    post.User_id         = Convert.ToInt32(Session["User_id"]);

                    PostManage.AddTopost(post);
                }

                var sdeadw = Session["Forution_id"].ToString();
                return(Content("<script>;alert('发表成功!');history.go(-2)</script>"));
            }
            catch (DbEntityValidationException ex)
            {
                return(Content(ex.Message));
            }
        }