public void UnFollowing(PERSON followingPerson, PERSON followerPerson) { using (TweetContext db = new TweetContext()) { //PERSON obj = db.persons.Find(person.user_id); PERSON objFollowing = db.persons.Include("followers").Include("following").Single(i => i.user_id == followingPerson.user_id); PERSON objFollowers = db.persons.Include("followers").Include("following").Single(i => i.user_id == followerPerson.user_id); List <PERSON> followingList = new List <PERSON>(); foreach (var item in objFollowers.following) { if (item == objFollowing) { objFollowers.following.Remove(objFollowing); break; } } //followingList.Add(objFollowing); ////followerList.Add(followerPerson); //objFollowers.followers = followingList; db.SaveChanges(); } }
public void AddTweet(TWEET tweet) { using (TweetContext db = new TweetContext()) { db.tweets.Add(tweet); db.SaveChanges(); } }
public override void Add(Event entity) { using (TweetContext context = GetContext()) { context.Events.Add(entity); context.SaveChanges(); } }
public void AddUser(PERSON item) { using (TweetContext db = new TweetContext()) { db.persons.Add(item); db.SaveChanges(); } }
public void DeleteProfile(string id) { using (TweetContext db = new TweetContext()) { PERSON obj = db.persons.Include("followers").Include("following").Include("tweet").Single(i => i.user_id == id); db.persons.Remove(obj); db.SaveChanges(); } }
public override void Add(Subscription entity) { using (TweetContext context = GetContext()) { context.Attach(entity.Event); context.Subscriptions.Add(entity); context.SaveChanges(); } }
public void DeleteTweet(TWEET tweet) { using (TweetContext db = new TweetContext()) { TWEET obj = db.tweets.Find(tweet.tweet_id); db.tweets.Remove(obj); db.SaveChanges(); } }
public override void Add(MediaUrl entity) { using (TweetContext context = GetContext()) { context.Attach(entity.Tweet); context.MediaUrls.Add(entity); context.SaveChanges(); } }
public void UpdateTweet(TWEET tweet) { using (TweetContext db = new TweetContext()) { TWEET obj = db.tweets.Find(tweet.tweet_id); obj.message = tweet.message; obj.created = tweet.created; db.SaveChanges(); } }
public void Edit(PERSON person) { using (TweetContext db = new TweetContext()) { PERSON obj = db.persons.Find(person.user_id); obj.fullName = person.fullName; obj.password = person.password; obj.email = person.email; db.SaveChanges(); } }
public override void Remove(long id) { using (TweetContext context = GetContext()) { User user = Get(id); if (user != null) { context.Users.Remove(user); context.SaveChanges(); } } }
public override void Add(User entity) { using (TweetContext context = GetContext()) { if (entity.Event != null) { context.Attach(entity.Event); } context.Users.Add(entity); context.SaveChanges(); } }
public override void Remove(long id) { using (TweetContext context = GetContext()) { Subscription subscription = Get(id); if (subscription != null) { context.Subscriptions.Remove(subscription); context.SaveChanges(); } } }
public override void Remove(long id) { using (TweetContext context = GetContext()) { Tweet tweet = Get(id); if (tweet != null) { context.Attach(tweet); context.Tweets.Remove(tweet); context.SaveChanges(); } } }
public void ToggleSticky(long id) { using (TweetContext context = GetContext()) { Tweet tweet = context.Tweets.Where(t => t.Id == id).SingleOrDefault(); if (tweet != null) { tweet.Sticky = !tweet.Sticky; context.Tweets.Update(tweet); context.SaveChanges(); } } }
public void SetVisibility(long id, bool visibility) { using (TweetContext context = GetContext()) { MediaUrl url = Get(id); if (url != null) { context.Attach(url); url.Visible = visibility; context.SaveChanges(); } } }
public override void Remove(long id) { using (TweetContext context = GetContext()) { MediaUrl url = Get(id); if (url != null) { context.Attach(url); context.MediaUrls.Remove(url); context.SaveChanges(); } } }
public void OnNext(Tweet tweet) { var value = new TweetResult(tweet); //LanguageAnalysis.AnalyzeLanguageAsync(tweet.Id.ToString(), tweet.Text).Wait(); //value.TweetId = tweet.Id; //value.Text = tweet.Text; //value.CreatedAt = ParseTwitterDateTime(tweet.CreatedAt); //value.TimeZone = tweet.User != null ? (tweet.User.TimeZone != null ? tweet.User.TimeZone : "(unknown)") : "(unknown)"; //value.Language = SentimentService.AnalyzeLanguageAsync(value.TweetId.ToString(), value.Text).Wait(); var language = SentimentService.AnalyzeLanguage(value.TweetId.ToString(), value.Text); value.LanguageName = String.Format("{0}({1})", language.Name, language.Iso639Name); value.LanguageConfidence = language.Score * 100; //value.RawJson = tweet.RawJson; value.SentimentScore = SentimentService.AnalyzeSentiment(value.TweetId.ToString(), value.Text, language.Iso639Name); value.KeyPhrases = SentimentService.AnalyzeKeyPhrases(value.TweetId.ToString(), value.Text, language.Iso639Name); using (TweetContext context = new TweetContext()) { context.TweetResults.Add(value); context.SaveChanges(); } //Console.WriteLine(); //Console.WriteLine("---------------------------------------------"); //Console.WriteLine(String.Format(" Tweet From {0} at {1}", value.ScreenName, value.CreatedAt.ToString())); //Console.WriteLine("---------------------------------------------"); //Console.WriteLine(String.Format(" Name: {0}", value.Name)); //Console.WriteLine(String.Format(" Screen Name: {0}", value.ScreenName)); //Console.WriteLine(String.Format(" Text: {0}", value.Text)); //Console.WriteLine(String.Format(" Language: {0}", value.LanguageName)); //Console.WriteLine(String.Format(" Language Confidence: {0}%", value.LanguageConfidence)); //Console.WriteLine(String.Format(" Sentiment Score: {0}%", value.SentimentScore)); //Console.WriteLine(" Key Phrases:"); //foreach (var keyPhrase in value.KeyPhrases) //{ // Console.WriteLine(String.Format(" {0}", keyPhrase)); //} //Console.WriteLine(String.Format(" TimeZone: {0}", value.TimeZone)); //Console.WriteLine(); //Console.ReadLine(); }
public int PopulateDatabase() { if (!_tweetContext.Tweets.Any()) { _tweetContext.Add(new Tweet { Id = 1, Descricao = "Tweet test 1", Imagem = "Image test 1", Usuario = "User test 1", Ativo = true }); _tweetContext.Add(new Tweet { Id = 2, Descricao = "Tweet test 2", Imagem = "Image test 2", Usuario = "User test 2", Ativo = true }); _tweetContext.Add(new Tweet { Id = 3, Descricao = "Tweet test 3", Imagem = "Image test 3", Usuario = "User test 3", Ativo = true }); } _tweetContext.SaveChanges(); return(_tweetContext.Tweets.Count()); }
public override void Remove(long id) { using (TweetContext context = GetContext()) { Event e = Get(id); if (e != null) { List <Tweet> tweets = context.Tweets.Where(t => t.Event.Id == e.Id).ToList(); List <User> users = context.Users.Where(u => u.Event.Id == e.Id).ToList(); List <Subscription> subs = context.Subscriptions.Where(s => s.Event.Id == e.Id).ToList(); context.Tweets.RemoveRange(tweets); context.Users.RemoveRange(users); context.Subscriptions.RemoveRange(subs); context.Attach(e); context.Events.Remove(e); context.SaveChanges(); } } }
protected void Save() { _context.SaveChanges(); }