示例#1
0
        public ActionResult Create(Page page)
        {
            page = Page.AddDateCreatedAndAuthor(page);

            if (ModelState.IsValid)
            {
                db.Pages.Add(page);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(page);
        }
示例#2
0
 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;
 }
示例#3
0
        //
        // 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");
        }
示例#4
0
        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);
        }