public ActionResult Create(FormCollection collection)
 {
     var page = new Page();
     if (_repository.GetPageByTitle(collection["Page.title"]) != null)
     {
         ModelState.AddModelError("Page.title", "Page title must be unique");
     }
     // This will try to update all the fields in the model based on the form collection
     if (TryUpdateModel(page, "Page", collection))
     {
         page.title = page.title.Trim();
         _repository.AddPage(page);
         _repository.Save();
         TempData["Message"] = "Page added";
         return RedirectToAction("Index");
     }
     return View("Create", MakeEditDataFromPage(page));
 }
 private PageEditData MakeEditDataFromPage(Page page)
 {
     return new PageEditData
             {
                 Page = page,
                 ExistingPages = _repository.GetAllPages()
             };
 }
示例#3
0
 public void AddPage(Page page)
 {
     page.id = ++_pageMaxId;
     _pages.Add(page);
 }
示例#4
0
 public void DeletePage(Page page)
 {
     _pages.Remove(page);
 }
 public void AddPage(Page page)
 {
     _conferenceware.Pages.InsertOnSubmit(page);
 }
 public void DeletePage(Page page)
 {
     _conferenceware.Pages.DeleteOnSubmit(page);
 }
 partial void DeletePage(Page instance);
 partial void UpdatePage(Page instance);
 partial void InsertPage(Page instance);