public IActionResult Create() { if (!authorized) return authorizationPrompt; var page = new Page { ID = db.Pages.Max(p => p.ID) + 1 }; ViewBag.Subtitle = "Create"; return View("Edit", page); }
public IActionResult Create(Page page) { if (!authorized) return authorizationPrompt; if (!ModelState.IsValid) { ViewBag.Subtitle = "Create"; return View("Edit", page); } db.Pages.Add(page); db.SaveChanges(); Cache.Reset(); ViewBag.Success = true; return RedirectToAction("Edit", new { id = page.ID }); }
public IActionResult Edit(Page page) { if (!authorized) return authorizationPrompt; ViewBag.Subtitle = "Edit – " + page.Title; if (!ModelState.IsValid) return View(page); db.Pages.Update(page); db.SaveChanges(); Cache.Reset(); ViewBag.Success = true; return View(page); }
private IActionResult SubPage(Page page) { ViewBag.Subtitle = page.Category + " – " + page.Title; ViewBag.Description = page.Description; return View("SubPage", page); }