public ActionResult Retweet(ReTweetBindingModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return Json(this.ModelState);
            }

            var tweet = this.Data.Tweets.Find(model.TweetId);

            if (tweet == null)
            {
                return this.Json("Not found");
            }

            var user = this.Data.Users.Find(this.User.Identity.GetUserId());

            if (tweet.UserId == user.Id)
            {
                throw new Exception("You can't retweet your own tweets");
            }

            if (user.Tweets.Any(t => t.ReplyToId == tweet.Id))
            {
                throw new Exception("You cannot retweet again");
            }

            this.Data.Tweets.Add(new Tweet()
            {
                Content = model.Content,
                UserId = user.Id,
                TweetDate = DateTime.Now,
                RetweetedTweetId = tweet.Id
            });

            tweet.User.Notifications.Add(new Notification()
            {
                Content = "Retweet",
                CreatorId = user.Id,
                RecipientId = tweet.UserId,
                Date = DateTime.Now,
                Type = NotificationType.Retweet
            });

            this.Data.SaveChanges();

            TwitterHub hub = new TwitterHub();

            //hub.NotificationInform(new List<string>() { tweet.User.UserName });

            return RedirectToAction("Index", "Home");
        }
        public ActionResult Retweet(ReTweetBindingModel 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 tweet = this.Data.Tweets.Find(model.TweetId);

            if (tweet == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.NotFound, "Tweet not found.");
            }

            var user = this.Data.Users.Find(this.User.Identity.GetUserId());

            if (tweet.UserId == user.Id)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest, "You can't retweet your own tweets.");
            }

            if (user.Tweets.Any(t => t.ReplyToId == tweet.Id))
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Retweeting retweet is not possible at the time.");
            }

            this.Data.Tweets.Add(new Tweet()
            {
                Content = model.Content,
                UserId = user.Id,
                TweetDate = DateTime.Now,
                RetweetedTweetId = tweet.Id
            });

            tweet.User.Notifications.Add(new Notification()
            {
                Content = "retweeted one of your tweets",
                CreatorId = user.Id,
                RecipientId = tweet.UserId,
                Date = DateTime.Now,
                Type = NotificationType.Retweet
            });

            this.Data.SaveChanges();

            TwitterHub hub = new TwitterHub();

            hub.NotificationInform(new List<string>() { tweet.User.UserName });

            return RedirectToAction("Index", "Home");
        }