public ActionResult Edit(int id) { WaitoPage pages_db = new WaitoEntities().WaitoPages.Where( p => p.PageId == id).FirstOrDefault(); Page page = new Page() { PageId = pages_db.PageId, PageName = pages_db.PageName, PageContent = pages_db.PageContent }; return View(page); }
public ActionResult Edit(Page page) { if (ModelState.IsValid) { using (WaitoEntities entities = new WaitoEntities()) { WaitoPage pages_db = entities.WaitoPages.Where(p => p.PageId == page.PageId).FirstOrDefault(); pages_db.PageName = page.PageName; pages_db.PageContent = page.PageContent; entities.SaveChanges(); } return RedirectToAction("Index"); } return View(); }
public ActionResult Create(Page page) { if (ModelState.IsValid) { using (WaitoEntities entities = new WaitoEntities()) { WaitoPage pages_db = new WaitoPage() { PageName = page.PageName, PageContent = page.PageContent }; entities.WaitoPages.Add(pages_db); entities.SaveChanges(); } return RedirectToAction("Index"); } return View(); }