public ActionResult Create(Page page) { if (ModelState.IsValid) { page.UserId = int.Parse((string)Session["UserId"]); page.Published = false; page.PublishedDate = DateTime.Now; db.Pages.Add(page); db.SaveChanges(); return RedirectToAction("Index"); } return View(page); }
public ActionResult Edit(Page page) { if (ModelState.IsValid) { page.UserId = int.Parse((string)Session["UserId"]); db.Pages.Attach(page); db.Entry(page).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(page); }