public ActionResult CreateBlog(Blogs newBlog) { using (CraigsDB db = new CraigsDB()) { db.craigsBlogs.Add(newBlog); db.SaveChanges(); } ModelState.Clear(); ViewBag.Message = "Your blog entry has been created."; return(View()); }
public ActionResult Registration(Users newAccount) { if (ModelState.IsValid) { using (CraigsDB db = new CraigsDB()) { db.craigsUsers.Add(newAccount); db.SaveChanges(); } ModelState.Clear(); ViewBag.Message = newAccount.Name + "'s account has been registered!"; } else { ModelState.AddModelError("", "Please try entering your details again"); } return(View()); }