public ActionResult Edit(BlogPost blogpost) { if (ModelState.IsValid) { context.Entry(blogpost).State = EntityState.Modified; context.SaveChanges(); return RedirectToAction("Index"); } return View(blogpost); }
public ActionResult Create(BlogPost blogpost) { blogpost.DatePosted = DateTime.Now.ToUniversalTime(); blogpost.DateLastModified = blogpost.DatePosted; if (ModelState.IsValid) { context.BlogPosts.Add(blogpost); context.SaveChanges(); return RedirectToAction("Index"); } return View(blogpost); }