public ActionResult CreateNews(FormCollection fc) { int userId = -1; if (Session["UserID"] != null) { userId = int.Parse(Convert.ToString(Session["UserID"])); } NewsModel news = new NewsModel(); BLLNews bll = new BLLNews(); NewsInfo newsObject = new NewsInfo() { Title = fc["Title"].ToString(), Content = fc["Message"].ToString(), CreateDate = DateTime.Now, IsDelete = false, IsPublic = Convert.ToBoolean(fc["IsPublic"]), IsTop = false, ViewTimes = 0, IsCommented = false, UserId = userId }; //保存到数据库 bll.Insert(newsObject); //返回到列表 return(RedirectToAction("Index")); }