Esempio n. 1
0
 public override IEnumerable <Event> Find(Func <Event, bool> exp)
 {
     using (TweetContext context = GetContext())
     {
         return(context.Events.Where <Event>(exp).ToList());
     }
 }
Esempio n. 2
0
 public override IEnumerable <User> Find(Func <User, bool> exp)
 {
     using (TweetContext context = GetContext())
     {
         return(context.Users.Include(u => u.Event).Where <User>(exp).ToList());
     }
 }
Esempio n. 3
0
 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);
     }
 }
Esempio n. 5
0
        //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());
     }
 }
Esempio n. 7
0
 public override IEnumerable <User> GetAll()
 {
     using (TweetContext context = GetContext())
     {
         return(context.Users.ToList());
     }
 }
Esempio n. 8
0
 public override Event Get(long id)
 {
     using (TweetContext context = GetContext())
     {
         return(context.Events.Where(e => e.Id == id).SingleOrDefault());
     }
 }
Esempio n. 9
0
 public override IEnumerable <Event> GetAll()
 {
     using (TweetContext context = GetContext())
     {
         return(context.Events.ToList());
     }
 }
Esempio n. 10
0
        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());
     }
 }
Esempio n. 12
0
 public void AddTweet(TWEET tweet)
 {
     using (TweetContext db = new TweetContext())
     {
         db.tweets.Add(tweet);
         db.SaveChanges();
     }
 }
Esempio n. 13
0
 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);
     }
 }
Esempio n. 14
0
 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);
     }
 }
Esempio n. 15
0
 public override void Add(Event entity)
 {
     using (TweetContext context = GetContext())
     {
         context.Events.Add(entity);
         context.SaveChanges();
     }
 }
Esempio n. 16
0
 public void AddUser(PERSON item)
 {
     using (TweetContext db = new TweetContext())
     {
         db.persons.Add(item);
         db.SaveChanges();
     }
 }
Esempio n. 17
0
 public PERSON GetByID(string id)
 {
     using (TweetContext db = new TweetContext())
     {
         PERSON obj = db.persons.Find(id);
         return(obj);
     }
 }
Esempio n. 18
0
 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();
     }
 }
Esempio n. 19
0
        public List <TWEET> GetAll()
        {
            using (TweetContext db = new TweetContext())
            {
                List <TWEET> alltweet = db.tweets.ToList();

                return(alltweet);
            }
        }
Esempio n. 20
0
 public void DeleteTweet(TWEET tweet)
 {
     using (TweetContext db = new TweetContext())
     {
         TWEET obj = db.tweets.Find(tweet.tweet_id);
         db.tweets.Remove(obj);
         db.SaveChanges();
     }
 }
Esempio n. 21
0
 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)));
     }
 }
Esempio n. 24
0
 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();
     }
 }
Esempio n. 25
0
 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();
         }
     }
 }
Esempio n. 27
0
        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);
        }
Esempio n. 28
0
 public override void Add(User entity)
 {
     using (TweetContext context = GetContext())
     {
         if (entity.Event != null)
         {
             context.Attach(entity.Event);
         }
         context.Users.Add(entity);
         context.SaveChanges();
     }
 }
Esempio n. 29
0
 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();
         }
     }
 }