Beispiel #1
0
        public ActionResult Create(Post post)
        {
            if (ModelState.IsValid)
            {
                db.Posts.Add(post);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.AuthorID = new SelectList(db.Authors, "AuthorID", "AuthorUserName", post.AuthorID);
            return View(post);
        }
Beispiel #2
0
 public ActionResult Edit(Post post)
 {
     if (ModelState.IsValid)
     {
         db.Entry(post).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.AuthorID = new SelectList(db.Authors, "AuthorID", "AuthorUserName", post.AuthorID);
     return View(post);
 }