public override void Add(Tweet entity) { using (TweetContext context = GetContext()) { context.Attach(entity.Event); context.Tweets.Add(entity); context.SaveChanges(); } }
public override void Add(MediaUrl entity) { using (TweetContext context = GetContext()) { context.Attach(entity.Tweet); context.MediaUrls.Add(entity); 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()) { Tweet tweet = Get(id); if (tweet != null) { context.Attach(tweet); context.Tweets.Remove(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 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(); } } }