public override IEnumerable <Event> Find(Func <Event, bool> exp) { using (TweetContext context = GetContext()) { return(context.Events.Where <Event>(exp).ToList()); } }
public override IEnumerable <User> Find(Func <User, bool> exp) { using (TweetContext context = GetContext()) { return(context.Users.Include(u => u.Event).Where <User>(exp).ToList()); } }
public override User Get(long id) { using (TweetContext context = GetContext()) { return(context.Users.Where(u => u.Id == id).SingleOrDefault()); } }
public override IEnumerable <MediaUrl> GetAll() { using (TweetContext context = GetContext()) { return(context.MediaUrls); } }
//public List<TWEET> GetById(string id) //{ //} public List <TWEET> GetById(string id) { using (TweetContext db = new TweetContext()) { UserBL obj = new UserBL(); List <string> followingList = obj.GetAllFollowingId(id); followingList.Add(id); List <TWEET> alltweetByUsers = new List <TWEET>(); foreach (var item in followingList) { var query = from p in db.tweets where p.user_id == item select new { user_id = p.user_id, message = p.message, created = p.created, tweet_id = p.tweet_id }; List <TWEET> alltweetByUserstweet = query.ToList().Select(r => new TWEET { tweet_id = r.tweet_id, user_id = r.user_id, message = r.message, created = r.created }).ToList(); foreach (var item1 in alltweetByUserstweet) { alltweetByUsers.Add(item1); } } //alltweetByUsers = alltweetByUsers.OrderByDescending(o => o.created).ToList(); return(alltweetByUsers.OrderByDescending(o => o.created).ToList()); } }
public override MediaUrl Get(long id) { using (TweetContext context = GetContext()) { return(context.MediaUrls.Where(m => m.Id == id).SingleOrDefault()); } }
public override IEnumerable <User> GetAll() { using (TweetContext context = GetContext()) { return(context.Users.ToList()); } }
public override Event Get(long id) { using (TweetContext context = GetContext()) { return(context.Events.Where(e => e.Id == id).SingleOrDefault()); } }
public override IEnumerable <Event> GetAll() { using (TweetContext context = GetContext()) { return(context.Events.ToList()); } }
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 override IEnumerable <MediaUrl> Find(Func <MediaUrl, bool> exp) { using (TweetContext context = GetContext()) { return(context.MediaUrls.Include(m => m.Tweet).Where <MediaUrl>(exp).ToList()); } }
public void AddTweet(TWEET tweet) { using (TweetContext db = new TweetContext()) { db.tweets.Add(tweet); db.SaveChanges(); } }
public List <string> GetAllUserId(string name) { using (TweetContext db = new TweetContext()) { List <string> listId = db.persons.Where(i => i.user_id.StartsWith(name)).Select(i => i.user_id).Distinct().ToList(); return(listId); } }
public PERSON Validate(string uname, string pwd) { using (TweetContext db = new TweetContext()) { PERSON obj = db.persons.SingleOrDefault(i => i.user_id == uname && i.password == pwd); return(obj); } }
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 PERSON GetByID(string id) { using (TweetContext db = new TweetContext()) { PERSON obj = db.persons.Find(id); return(obj); } }
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 List <TWEET> GetAll() { using (TweetContext db = new TweetContext()) { List <TWEET> alltweet = db.tweets.ToList(); return(alltweet); } }
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 override void Add(Subscription entity) { using (TweetContext context = GetContext()) { context.Attach(entity.Event); context.Subscriptions.Add(entity); context.SaveChanges(); } }
public Tweet GetLastTweet() { using (TweetContext context = GetContext()) { return(context.Tweets .Include(t => t.MediaList) .Include(t => t.Event) .FirstOrDefault(t => t.Date == context.Tweets.Max(x => x.Date))); } }
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()) { Subscription subscription = Get(id); if (subscription != null) { context.Subscriptions.Remove(subscription); context.SaveChanges(); } } }
protected void AddStatus(Status status) { TweetContext tweet = new TweetContext() { User = status.User, Tweet = status.Text, Time = status.CreatedAt, Country = status.Place.Country ?? "Unknown" }; Tweets.Add(tweet); }
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()) { User user = Get(id); if (user != null) { context.Users.Remove(user); 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(); } } }