Ejemplo n.º 1
0
        public static List <UserModel> AddFriends(List <int> friendsId, int ownerId)
        {
            List <UserModel> friendsList = new List <UserModel>();


            for (int i = 0; i < 10; i++)
            {
                JObject   friendInfo = ApiVkRequests.GetUserInfo(friendsId[i].ToString());
                UserModel friend     = new UserModel();

                List <PostModel> postsList = new List <PostModel>();
                postsList.Clear();
                friend.ownerId   = ownerId;
                friend.Id        = Convert.ToInt32(Parser.GetUserId(friendInfo));
                friend.FirstName = Parser.GetUserFirstName(friendInfo);
                friend.LastName  = Parser.GetUserLastName(friendInfo);
                friend.City      = Parser.GetUserCity(friendInfo);
                List <int> postsId = Parser.GetUserPosts(ApiVkRequests.GetUserPosts(friendsId[i]));

                for (int j = 0; j < postsId.Count; j++)
                {
                    PostModel postModel = new PostModel();
                    postModel.userId = friendsId[i];
                    postModel.id     = postsId[j];
                    postModel.Date   = Parser.GetDate(ApiVkRequests.GetUserPosts(friendsId[i]), postsId[j]);
                    postsList.Add(postModel);
                }

                Console.WriteLine(postsList.Count);
                friend.Posts = postsList;
                friendsList.Add(friend);
            }
            return(friendsList);
        }
Ejemplo n.º 2
0
        public static void AddAllFriends(string linq)
        {
            List <UserModel> friendsList    = new List <UserModel>();
            List <UserModel> ownersList     = new List <UserModel>();
            JObject          userInfo       = ApiVkRequests.GetUserInfo(Parser.ParserLink(linq));
            string           currentOwnerId = Parser.GetUserId(userInfo);
            List <int>       friendsId      = Parser.ParseFriendsId(ApiVkRequests.GetUserFriends(currentOwnerId));
            UserModel        currentOwner   = UserAdder.AddMainUser(Convert.ToInt32(currentOwnerId));

            ownersList.Add(currentOwner);
            friendsList.AddRange(UserAdder.AddFriends(friendsId, Convert.ToInt32(currentOwnerId)));
            UserAdder.InsertMainUser(currentOwner);
            UserAdder.InsertFriends(friendsList);
        }
Ejemplo n.º 3
0
        public static UserModel AddMainUser(int userId)
        {
            UserModel        user     = new UserModel();
            List <PostModel> posts    = new List <PostModel>();
            PostModel        post     = new PostModel();
            JObject          userInfo = ApiVkRequests.GetUserInfo(userId.ToString());

            user.Id        = Convert.ToInt32(Parser.GetUserId(userInfo));
            user.FirstName = Parser.GetUserFirstName(userInfo);
            user.LastName  = Parser.GetUserLastName(userInfo);
            List <int> postsId = Parser.GetUserPosts(ApiVkRequests.GetUserPosts(userId));

            for (int j = 0; j < postsId.Count; j++)
            {
                post.userId = userId;
                post.id     = postsId[j];
                post.Date   = Parser.GetDate(ApiVkRequests.GetUserPosts(userId), postsId[j]);
                posts.Add(post);
            }

            user.Posts = posts;
            return(user);
        }
Ejemplo n.º 4
0
        public static void UpdateAllFriends(string currentOwnerId)
        {
            UserUpdater.AddNewFriends(UserUpdater.CheckCurrentFriends(UserUpdater.ReturnFriendsList(currentOwnerId)), currentOwnerId);
            List <int>       friendsId = Parser.ParseFriendsId(ApiVkRequests.GetUserFriends(currentOwnerId));
            List <PostModel> postsList = new List <PostModel>();

            foreach (int friend in friendsId)
            {
                MySqlQuery.DeleteFriendPosts(friend.ToString());

                List <int> postsId = Parser.GetUserPosts(ApiVkRequests.GetUserPosts(friend));


                for (int j = 0; j < postsId.Count; j++)
                {
                    PostModel postModel = new PostModel();
                    postModel.userId = friend;
                    postModel.id     = postsId[j];
                    postModel.Date   = Parser.GetDate(ApiVkRequests.GetUserPosts(friend), postsId[j]);
                    postsList.Add(postModel);
                }
                MySqlQuery.insertNewPosts(postsList, friend.ToString());
            }
        }
Ejemplo n.º 5
0
        public static List <int> ReturnFriendsList(string currentOwnerId)
        {
            List <int> friendsId = Parser.ParseFriendsId(ApiVkRequests.GetUserFriends(currentOwnerId));

            return(friendsId);
        }