Beispiel #1
0
        public void Signup(PERSON pObj)
        {
            TwitterDBContext twitterDBContext = new TwitterDBContext();

            twitterDBContext.People.Add(pObj);
            twitterDBContext.SaveChanges();
        }
Beispiel #2
0
        public PERSON SearchUser(string id)
        {
            TwitterDBContext twitterDBContext = new TwitterDBContext();
            var result = twitterDBContext.People.Where(m => m.user_id == id && m.active == true).First();

            return(result);
        }
Beispiel #3
0
        public void FollowUser(FOLLOWING following)
        {
            TwitterDBContext twitterDBContext = new TwitterDBContext();

            twitterDBContext.FOLLOWINGs.Add(following);
            twitterDBContext.SaveChanges();
        }
Beispiel #4
0
        public int Login(Person pObj)
        {
            TwitterDBContext twitterDBContext = new TwitterDBContext();
            var result = twitterDBContext.People.Where(m => m.user_id == pObj.user_id && m.password == pObj.password && m.active == true).Count();

            return(result);
        }
Beispiel #5
0
        public void DeactivateAccount(string id)
        {
            TwitterDBContext twitterDBContext = new TwitterDBContext();
            var result = twitterDBContext.People.Where(m => m.user_id == id).First();

            result.active = false;
            twitterDBContext.SaveChanges();
        }
Beispiel #6
0
        public void UnFollowUser(string id, string user)
        {
            TwitterDBContext twitterDBContext = new TwitterDBContext();
            var delObj = twitterDBContext.FOLLOWINGs.Where(m => m.user_id == user && m.following_id == id).First();

            twitterDBContext.FOLLOWINGs.Remove(delObj);
            twitterDBContext.SaveChanges();
        }
Beispiel #7
0
        public void EditProfile(PERSON pObj)
        {
            TwitterDBContext twitterDBContext = new TwitterDBContext();
            var person = twitterDBContext.People.Where(m => m.user_id == pObj.user_id).FirstOrDefault();

            person.fullName = pObj.fullName;
            person.email    = pObj.email;
            person.password = pObj.password;
            twitterDBContext.SaveChanges();
        }
Beispiel #8
0
        public Profile NewTweet(Tweet tweet, string user)
        {
            TwitterDBContext twitterDBContext = new TwitterDBContext();

            Assignment1.TWEET tObj = new TWEET();
            tObj.user_id = user;
            tObj.message = tweet.message;
            tObj.created = DateTime.Now;
            twitterDBContext.TWEETs.Add(tObj);
            twitterDBContext.SaveChanges();

            var     person     = twitterDBContext.People.Where(m => m.user_id == user).FirstOrDefault();
            Profile pObj       = new Profile();
            var     selfTweets = person.TWEETs;

            pObj.selfTweets = new List <Tweet>();
            foreach (var item in selfTweets)
            {
                pObj.selfTweets.Add(new Tweet {
                    created = item.created, message = item.message, user_id = item.user_id
                });
            }

            var following = person.FOLLOWINGs1;

            pObj.following = new List <Person>();
            foreach (var item in following)
            {
                pObj.following.Add(new Person {
                    user_id = item.following_id
                });
            }

            pObj.allTweets = new List <Tweet>();
            pObj.allTweets.AddRange(pObj.selfTweets);
            foreach (var item in pObj.following)
            {
                var followingTweet = twitterDBContext.TWEETs.Where(m => m.user_id == item.user_id);
                foreach (var value in followingTweet)
                {
                    pObj.allTweets.Add(new Tweet {
                        created = value.created, message = value.message, user_id = value.user_id
                    });
                }
            }

            pObj.allTweets = pObj.allTweets.OrderByDescending(m => m.created).ToList();
            return(pObj);
        }
 public ActionResult UnFollowUser(string id)
 {
     if (id == Session["user"].ToString())
     {
         return(Json("UnFollow option is for other user's profile!", JsonRequestBehavior.AllowGet));
     }
     try
     {
         string           user             = Session["user"].ToString();
         TwitterDBContext twitterDBContext = new TwitterDBContext();
         dalLayer.UnFollowUser(id, user);
         return(Json(id + " - unfollowed!", JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #10
0
        public Profile LoadProfilePage(string id)
        {
            TwitterDBContext twitterDBContext = new TwitterDBContext();
            var     person      = twitterDBContext.People.Where(m => m.user_id == id).FirstOrDefault();
            Profile profilePage = new Profile();

            profilePage.user_id = person.user_id;
            var selfTweets = person.TWEETs;

            profilePage.selfTweets = new List <Tweet>();
            foreach (var item in selfTweets)
            {
                profilePage.selfTweets.Add(new Tweet {
                    created = item.created, message = item.message, tweet_id = item.tweet_id
                });
            }
            profilePage.selfTweets = profilePage.selfTweets.OrderByDescending(m => m.created).ToList();
            var following = person.FOLLOWINGs1;

            profilePage.following = new List <Person>();
            foreach (var item in following)
            {
                profilePage.following.Add(new Person {
                    user_id = item.following_id
                });
            }
            var followers = person.FOLLOWINGs;

            profilePage.followers = new List <Person>();
            foreach (var item in followers)
            {
                profilePage.followers.Add(new Person {
                    user_id = item.user_id
                });
            }
            profilePage.fullName = person.fullName;
            profilePage.email    = person.email;
            profilePage.joined   = person.joined;
            return(profilePage);
        }
Beispiel #11
0
        public Profile DeleteTweet(Tweet tweet, string user)
        {
            TwitterDBContext twitterDBContext = new TwitterDBContext();
            var tObj = twitterDBContext.TWEETs.Where(m => m.tweet_id == tweet.tweet_id).FirstOrDefault();

            twitterDBContext.TWEETs.Remove(tObj);
            twitterDBContext.SaveChanges();

            var     person     = twitterDBContext.People.Where(m => m.user_id == user).FirstOrDefault();
            Profile pObj       = new Profile();
            var     selfTweets = person.TWEETs;

            pObj.selfTweets = new List <Tweet>();
            foreach (var item in selfTweets)
            {
                pObj.selfTweets.Add(new Tweet {
                    created = item.created, message = item.message, user_id = item.user_id
                });
            }

            pObj.selfTweets = pObj.selfTweets.OrderByDescending(m => m.created).ToList();
            return(pObj);
        }
Beispiel #12
0
 public RetweetTagHelper(TwitterDBContext context, UserManager <User> userManager)
 {
     _context     = context;
     _userManager = userManager;
 }
Beispiel #13
0
 public Message(TwitterDBContext context)
 {
     _context = context;
 }
Beispiel #14
0
 public Tweet(TwitterDBContext context, UserManager <User> userManager)
 {
     _context     = context;
     _userManager = userManager;
 }
Beispiel #15
0
 public ChatHub(UserManager <User> userManager, TwitterDBContext context)
 {
     _userManager = userManager;
     _context     = context;
 }
Beispiel #16
0
        public Profile LoadProfileHome(string id)
        {
            TwitterDBContext twitterDBContext = new TwitterDBContext();
            var     person      = twitterDBContext.People.Where(m => m.user_id == id).FirstOrDefault();
            Profile profileHome = new Profile();

            profileHome.user_id = person.user_id;
            var selfTweets = person.TWEETs;

            profileHome.selfTweets = new List <Tweet>();
            foreach (var item in selfTweets)
            {
                profileHome.selfTweets.Add(new Tweet
                {
                    created  = item.created,
                    message  = item.message,
                    user_id  = item.user_id,
                    tweet_id = item.tweet_id
                });
            }

            var following = person.FOLLOWINGs1;

            profileHome.following = new List <Person>();
            foreach (var item in following)
            {
                profileHome.following.Add(new Person {
                    user_id = item.following_id
                });
            }

            profileHome.allTweets = new List <Tweet>();
            profileHome.allTweets.AddRange(profileHome.selfTweets);
            foreach (var item in profileHome.following)
            {
                var followingTweet = twitterDBContext.TWEETs.Where(m => m.user_id == item.user_id);
                foreach (var value in followingTweet)
                {
                    profileHome.allTweets.Add(new Tweet {
                        created = value.created, message = value.message, user_id = value.user_id, tweet_id = value.tweet_id
                    });
                }
            }

            profileHome.allTweets = profileHome.allTweets.OrderByDescending(m => m.created).ToList();

            var followers = person.FOLLOWINGs;

            profileHome.followers = new List <Person>();
            foreach (var item in followers)
            {
                profileHome.followers.Add(new Person {
                    user_id = item.user_id
                });
            }
            profileHome.tweetCount     = person.TWEETs.Count;
            profileHome.followersCount = person.FOLLOWINGs.Count;
            profileHome.followingCount = person.FOLLOWINGs1.Count;
            profileHome.fullName       = person.fullName;
            profileHome.email          = person.email;
            profileHome.joined         = person.joined;
            var twitterUsers = twitterDBContext.People;

            profileHome.twitterUsers = new List <Person>();
            foreach (var item in twitterUsers)
            {
                profileHome.twitterUsers.Add(new Person {
                    user_id = item.user_id
                });
            }
            return(profileHome);
        }
Beispiel #17
0
 public HomeController(TwitterDBContext context, UserManager <User> userManager, IHostingEnvironment appEnvironment)
 {
     _context        = context;
     _userManager    = userManager;
     _appEnvironment = appEnvironment;
 }
Beispiel #18
0
 public TweetsController(UserManager <User> userManager, TwitterDBContext context)
 {
     _context     = context;
     _userManager = userManager;
 }
Beispiel #19
0
 public ProfileController(UserManager <User> userManager, TwitterDBContext context)
 {
     _userManager = userManager;
     _context     = context;
 }
Beispiel #20
0
 public Reply(TwitterDBContext context)
 {
     _context = context;
 }
Beispiel #21
0
 public HomeController(TwitterDBContext context, UserManager <User> userManager)
 {
     _context     = context;
     _userManager = userManager;
 }
Beispiel #22
0
 public MessagesController(UserManager <User> userManager, TwitterDBContext context)
 {
     _userManager = userManager;
     _context     = context;
 }