public ActionResult Create() { var msg = new Message{ Name = User.Identity.IsAuthenticated ? User.Identity.Name : "" }; return View(msg); }
public ActionResult Create(Message message) { if (ModelState.IsValid) { message.DatePosted = DateTime.Now; _db.Messages.Add(message); _db.SaveChanges(); return RedirectToAction("Index"); } return View(message); }