public static USERFollowerDTO AddFollower(USERFollowerDTO userTrack)
        {
            USERFollowerDTO newFollowee = new USERFollowerDTO();

            try
            {
                using (CMSTweetDBEntities111 context = new CMSTweetDBEntities111())
                {
                    UserFollower followee = new UserFollower
                    {
                        FollowerId = userTrack.FollowerId,
                        UserId     = userTrack.UserId
                    };
                    context.UserFollowers.Add(followee);
                    context.SaveChanges();

                    {
                        newFollowee.UserId     = followee.UserId;
                        newFollowee.FollowerId = followee.FollowerId;
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return(newFollowee);
        }
Пример #2
0
        public static USERFollowerDTO AddFollower(string email, string password, int followerid, int followingid)
        {
            if (!USERFollowerDataLinker.CheckUserLoggedIn(email, password))
            {
                //If user is not logged in
                return(null);
            }
            else
            {
                USERFollowerDTO userdto = new USERFollowerDTO()
                {
                    FollowerId = followerid,
                    UserId     = followingid
                };

                USERFollowerDTO addFollowing = USERFollowerDataLinker.AddFollower(userdto);

                if (addFollowing != null)
                {
                    return(addFollowing);
                }
                else
                {
                    return(null);
                }
            }
        }
Пример #3
0
        public static bool UnFollow(USERFollowerDTO newTrack)
        {
            //if (!USERFollowerDataLinker.CheckUserLoggedIn(email, password))
            //{
            //    //User logged out
            //    return false;
            //}

            USERFollowerDTO followee = new USERFollowerDTO
            {
                UserId     = newTrack.FollowerId,
                FollowerId = newTrack.UserId
            };

            return(USERFollowerDataLinker.UnFollow(followee));
        }
 public static bool UnFollow(USERFollowerDTO followee)
 {
     try
     {
         using (CMSTweetDBEntities111 context = new CMSTweetDBEntities111())
         {
             var following = (from followings in context.UserFollowers
                              where followings.FollowerId == followee.FollowerId &&
                              followings.UserId == followee.UserId
                              select followings).FirstOrDefault();
             if (following == null)
             {
                 return(false);
             }
             context.UserFollowers.Remove(following);
             context.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #5
0
 public static IList <UserDetails> GetFollowers(string email, string password, int followeeid)
 {
     if (!USERFollowerDataLinker.CheckUserLoggedIn(email, password))
     {
         //User logged out
         return(null);
     }
     else
     {
         USERFollowerDTO obj = new USERFollowerDTO()
         {
             UserId = followeeid
         };
         IList <UserDetails> getFollowers = USERFollowerDataLinker.GetFollowers(obj.UserId);
         if (getFollowers != null)
         {
             return(getFollowers);
         }
         else
         {
             return(null);
         }
     }
 }
Пример #6
0
 public static IList <UserDetails> GetFollowees(string email, string password, int followerId)
 {
     if (!USERFollowerDataLinker.CheckUserLoggedIn(email, password))
     {
         //If user is not logged in
         return(null);
     }
     else
     {
         USERFollowerDTO obj = new USERFollowerDTO()
         {
             FollowerId = followerId
         };
         IList <UserDetails> getFollowees = USERFollowerDataLinker.GetFollowees(obj.FollowerId);
         if (getFollowees != null)
         {
             return(getFollowees);
         }
         else
         {
             return(null);
         }
     }
 }
Пример #7
0
 public bool UnfollowUser(USERFollowerDTO newTrack)
 {
     return(UserFollowerBL.UnFollow(newTrack));
 }