// GET: /Tweets/ public ActionResult Index() { if (Session["Username"] == null) { return(RedirectToAction("Login")); } var model = new TweetFormViewModel(); model.Tweets = tweetService.GetTweets(); return(View(model)); }
public ActionResult Index([Bind(Include = "TweetMessage")] TweetFormViewModel model) { if (Session["Username"] == null) { return(RedirectToAction("Login")); } var tweetModel = new TweetViewModel(); tweetModel.TweetMessage = model.TweetMessage; tweetModel.FullName = Session["Username"].ToString(); tweetService.AddNewTweet(tweetModel); return(RedirectToAction("Index")); //we need to do this to avoid the postback of the page }