public ActionResult Create(Page page) { page = Page.AddDateCreatedAndAuthor(page); if (ModelState.IsValid) { db.Pages.Add(page); db.SaveChanges(); return RedirectToAction("Index"); } return View(page); }
public static Page AddDateCreatedAndAuthor(Page page) { page.DateCreated = DateTime.Now; if (HttpContext.Current.User.Identity.IsAuthenticated) page.Author = Membership.GetUser().UserName; else page.Author = "NoAuthor"; return page; }
// // POST: /CV/Finish public ActionResult Finish() { System.Web.Configuration.WebConfigurationManager.AppSettings.Set("AreRegistrationsAllowed","false"); List<string> users = db.ApplicationCVs.Where(r => r.IsAccepted == true).Select(r => r.UserName).ToList(); Page page = new Page(); page = Page.AddDateCreatedAndAuthor(page); page.Content = "<p>And the participants are:</p><ul>"; foreach(var user in users){ page.Content += "<li>" + user + "</li>"; } page.Content += "</ul>"; page.IsMenu = true; page.IsBlog = false; page.IsComment = false; page.IsSticky = false; page.Title = "Participants"; db.Pages.Add(page); db.SaveChanges(); return RedirectToAction("Index", "Home"); }
public ActionResult Edit(Page page) { page = Page.AddDateCreatedAndAuthor(page); if (ModelState.IsValid) { db.Entry(page).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(page); }