public ActionResult CreatePage(StaticPage page) { var manager = new AdminManager(); var pageCount = manager.GetAllPages().Count; manager.AddPage(page); page.PageDate = DateTime.Now; if (pageCount == 0) { page.PageID = 1; } else page.PageID = manager.GetAllPages().Count + 1; return RedirectToAction("Index", "Home"); }
public void CanAddStaticPage() { var manager = new AdminManager(); var pageCount = manager.GetAllPages().Count; var toAdd = new StaticPage(); toAdd.PageID = pageCount + 1; toAdd.PageTitle = "Test title"; toAdd.PageBody = "test static page"; toAdd.PageDate = DateTime.Now; manager.AddPage(toAdd); var secondCount = manager.GetAllPages().Count; Assert.AreEqual(pageCount +1, secondCount); }
// GET: StaticPage public ActionResult PageIndex() { var manager = new AdminManager(); var pages = manager.GetAllPages(); return View(pages); }
public void CanDeleteStaticPage() { var manager = new AdminManager(); var pageCount = manager.GetAllPages().Count; var page = manager.GetPageByID(pageCount); manager.DeletePage(page); var secondCount = manager.GetAllPages().Count; Assert.AreEqual(pageCount -1, secondCount); }
public void CancEditStaticPage() { var manager = new AdminManager(); var toEdit = manager.GetPageByID(manager.GetAllPages().Count); toEdit.PageTitle = "Edited Static Page Title"; manager.EditPage(toEdit); var toCheck = manager.GetPageByID(manager.GetAllPages().Count); Assert.AreEqual(toEdit.PageTitle, toCheck.PageTitle); }
public IEnumerable<StaticPage> Get() { var repo = new AdminManager(); return repo.GetAllPages(); }