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); }
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()); } }
public static List <int> ReturnFriendsList(string currentOwnerId) { List <int> friendsId = Parser.ParseFriendsId(ApiVkRequests.GetUserFriends(currentOwnerId)); return(friendsId); }