private async Task <Dictionary <long, List <VkWallResponse> > > CheckUpdates() { Dictionary <long, List <VkWallResponse> > usersPosts = new Dictionary <long, List <VkWallResponse> >(); foreach (var userId in _userIdList) { var postDto = new PostDTOModel() { AccountId = userId }; var wall = await VkClient.GetUserPosts(postDto); //if (wall.Response.Items.Any(x => x.Date > DateTime.Now.AddMinutes(-10))) //{ // if (usersPosts.ContainsKey(userId)) // { // usersPosts[userId].Add(wall); // } // else // { // usersPosts.Add(userId, new List<VkWallResponse>() { wall }); // } //} } return(usersPosts); }
public async Task <IEnumerable <PostDTO> > GetUserPosts([FromBody] PostDTOModel postModel) { var postList = new List <PostDTO>(); var vkPosts = await VkClient.GetUserPosts(new PostDTOModel { AccountId = 35340109, Token = postModel.Token }); //var vkPosts2 = await VkClient.GetUserPosts(new PostDTOModel { AccountId = 68038156, Token = postModel.Token}); var vkPosts3 = await VkClient.GetUserPosts(new PostDTOModel { AccountId = 55325758, Token = postModel.Token }); var usr = VkClient.GetUser(postModel.Token, 35340109); var usr2 = VkClient.GetUser(postModel.Token, 68038156); var usr3 = VkClient.GetUser(postModel.Token, 55325758); List <Item> postList3 = new List <Item>(); postList3 = postList3.Concat(vkPosts.Response.Items).ToList(); // postList3.Concat(vkPosts2.Response.Items); postList3 = postList3.Concat(vkPosts3.Response.Items).ToList(); //vkPosts.Response.Items.Add(vkPosts2.Response.Items); string[] arr = new string[] { }; foreach (var pst in vkPosts.Response.Items) { postList.Add(new PostDTO { Id = pst.Id.ToString(), FirstName = usr.FirstName, LastName = usr.LastName, AvatarUrl = usr.PhotoUrl, Text = pst.Text, Likes = pst.Likes.Count, Images = arr }); } foreach (var pst in vkPosts3.Response.Items) { postList.Add(new PostDTO { Id = pst.Id.ToString(), FirstName = usr3.FirstName, LastName = usr3.LastName, AvatarUrl = usr3.PhotoUrl, Text = pst.Text, Likes = pst.Likes.Count, Images = arr }); } return(postList); }