public ActionResult Tweet(CreateTweetBindingModel model) { if (!this.ModelState.IsValid) { return Json(this.ModelState); } var user = this.Data.Users.Find(this.User.Identity.GetUserId()); var tweet = new Tweet() { Content = model.Content, UserId = user.Id, TweetDate = DateTime.Now }; this.Data.Tweets.Add(tweet); this.Data.SaveChanges(); TwitterHub hub = new TwitterHub(); //hub.InformFollowers(user.Followers.Select(u => u.Id).ToList(), tweet.Id); return RedirectToAction("Index", "Home"); }
public ActionResult Tweet(CreateTweetBindingModel model) { if (model == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Missing data"); } if (!this.ModelState.IsValid) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest, JsonConvert.SerializeObject(this.ModelState)); } var user = this.Data.Users.Find(this.User.Identity.GetUserId()); var tweet = new Tweet() { Content = model.Content, UserId = user.Id, TweetDate = DateTime.Now }; this.Data.Tweets.Add(tweet); this.Data.SaveChanges(); TwitterHub hub = new TwitterHub(); hub.InformFollowers(user.Followers.Select(u => u.UserName).ToList(), tweet.Id); return PartialView("_FullTweetPartial", Mapper.Map<TweetViewModel>(tweet)); }