コード例 #1
0
 public ActionResult Edit(Article article)
 {
     if (ModelState.IsValid)
     {
         db.Entry(article).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(article);
 }
コード例 #2
0
        public ActionResult Create(Article article)
        {
            if (ModelState.IsValid)
            {
                article.Posted = DateTime.Now;
                article.Read = 0;
                article.Like = 0;
                db.Articles.Add(article);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(article);
        }