/* * List<Status> tweets = * await * (from tweet in twitterCtx.Status * where tweet.Type == StatusType.User && * tweet.ScreenName == "JoeMayo" && * tweet.ScreenName == twitterHandle && * tweet.Count == MaxTweetsToReturn && * tweet.SinceID == sinceID && * tweet.TweetMode == TweetMode.Extended * select tweet) * .ToListAsync(); * * if (tweets != null) * if (tweets != null && tweets.Any()) * { * combinedSearchResults.AddRange(tweets); * ulong previousMaxID = ulong.MaxValue; * do * { * using(PolitiFactContext db = new PolitiFactContext()) * { * * } * // one less than the newest id you've just queried * maxID = tweets.Min(status => status.StatusID) - 1; * * Debug.Assert(maxID < previousMaxID); * previousMaxID = maxID; * * tweets = * await * (from tweet in twitterCtx.Status * where tweet.Type == StatusType.User && * tweet.ScreenName == "JoeMayo" && * tweet.Count == MaxTweetsToReturn && * tweet.MaxID == maxID && * tweet.SinceID == sinceID && * tweet.TweetMode == TweetMode.Extended * select tweet) * .ToListAsync(); * * combinedSearchResults.AddRange(tweets); * * } while (tweets.Any() && combinedSearchResults.Count < MaxTotalResults); */ static void WriteTweetsToDatabase(List <Status> tweets, string twitterHandle, int presidentialCandidateID) { using (PolitiFactContext db = new PolitiFactContext()) { foreach (var tweet in tweets) { long userID = 0; Int64.TryParse(tweet.User.UserIDResponse, out userID); Tweet statusAsTweet = new Tweet { Text = tweet?.FullText ?? "", TwitterUserId = userID, TwitterName = twitterHandle, PoliticalCandidate = presidentialCandidateID, Time = tweet.CreatedAt }; db.Tweet.Add(statusAsTweet); } db.SaveChanges(); Console.Write("Saved a total of " + tweets.Count + " tweets to the database for " + twitterHandle); } }
public HomeController(PolitiFactContext context) { _context = context; }
/* * */ public TweetController(PolitiFactContext context) { _context = context; }
public ValuesController(PolitiFactContext context) { _context = context; }