public ActionResult Create(News news) { if (ModelState.IsValid) { DateTime saveNow = DateTime.Now; news.PublishTime = saveNow; db.News.Add(news); db.SaveChanges(); return RedirectToAction("Index"); } return View(news); }
public ActionResult Edit(News news) { if (ModelState.IsValid) { db.Entry(news).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(news); }