public ActionResult Retweet(int tweetId) { var userId = this.User.Identity.GetUserId(); if (!this.Data.Retweets.Any(r => r.TweetId == tweetId && r.UserId == userId)) { this.Data.Retweets.Add(new Retweet { TweetId = tweetId, UserId = userId }); this.Data.SaveChanges(); } var addNotification = new NotificationsController(); addNotification.PostNotification(new NotificationsBindingModel { ReceiverId = this.Data.Tweets.FirstOrDefault(t => t.Id == tweetId).AuthorId, Content = "Retweeted your tweet.", SenderId = userId }); //TODO: Add the retweeted tweet to the person who retweeted it. return(this.RedirectToAction("Index", "Home")); }
public ActionResult Retweet(int tweetId) { var userId = User.Identity.GetUserId(); if (!Data.Retweets.Any(r => r.TweetId == tweetId && r.UserId == userId)) { Data.Retweets.Add(new Retweet { TweetId = tweetId, UserId = userId }); Data.SaveChanges(); } var addNotification = new NotificationsController(); addNotification.PostNotification(new NotificationsBindingModel { ReceiverId = Data.Tweets.FirstOrDefault(t => t.Id == tweetId).AuthorId, Content = "Retweeted your tweet.", SenderId = userId, }); //TODO: Add the retweeted tweet to the person who retweeted it. return RedirectToAction("Index", "Home"); }