public ActionResult Index() { User user = new User(); // returns messages (of those they are following) for current user IList<UserMessage> messages = _context.GetMessagesForUser(user); // insert current user id MessageViewModel model = new MessageViewModel { Messages = messages }; return View(model); }
public ActionResult Index(MessageViewModel model) { if (ModelState.IsValid) { _context.Create(model.NewMessage); _context.SaveChanges(); TempData["Message"] = "Your message has been posted."; return RedirectToAction("Index"); } else { TempData["Message"] = "There has been an error. Please try again."; return View(model); } }