public ActionResult Edit(Page page) { if (ModelState.IsValid) { this.pageRepository.InsertOrUpdate(page); this.pageRepository.Save(); return RedirectToAction("Index"); } return this.View(); }
public void InsertOrUpdate(Page page) { if (page.PageId == default(int)) { // New entity this.context.Pages.Add(page); } else { // Existing entity this.context.Entry(page).State = EntityState.Modified; } }