コード例 #1
0
        public ActionResult NewsCreate(FormCollection collection, News news, HttpPostedFileBase fileImg)
        {
            int idmem = 0;

            if (Session["uId"] != null)
            {
                idmem = int.Parse(Session["uId"].ToString());
            }
            if (Request.Cookies["Username"] != null)
            {
                news.Name    = collection["Name"];
                news.Tag     = StringClass.NameToTag(collection["Name"]);
                news.Image   = collection["Image"];
                news.Content = collection["Content"];
                news.Detail  = collection["Detail"];
                int GroupNews = Convert.ToInt32(collection["GroupNews"]);
                news.IdGroup     = GroupNews;
                news.Keyword     = collection["Keyword"];
                news.Description = collection["Description"];
                news.Title       = collection["Title"];
                news.Ord         = Convert.ToInt32(collection["Ord"]);
                news.Index       = (collection["Index"] == "false") ? false : true;
                news.Active      = (collection["Active"] == "false") ? false : true;
                news.Lang        = Session["Lang"] != null ? Session["Lang"].ToString() : "vi";
                news.View        = 0;//so luot xem
                news.SDate       = DateTime.Now;
                db.sp_News_Insert(news.Name, news.Tag, news.Title, news.Keyword, news.Description, news.Image, news.SDate, news.Content, news.Detail, news.Index, news.View, news.IdGroup, news.Ord, news.Active, news.Lang);
                db.SaveChanges();
                return(RedirectToAction("NewsIndexot"));
            }
            else
            {
                return(Redirect("/Admins/admins"));
            }
        }