private void fetchPosts() { //for post comps = new List <PostComponent>(); postList = new List <PInstaSR.Post>(); try { PInstaSR.IpostServiceClient client = new PInstaSR.IpostServiceClient(); PInstaSR.Post[] postlist = null; foreach (UInstaSR.User u in this.followers) { postlist = client.fetchPost(u.userId); foreach (var post in postlist) { postList.Add((PInstaSR.Post)post); } } Debug.WriteLine(postList.Count); List <PInstaSR.Post> temp = this.postList.OrderByDescending(p => p.creation_date).ToList(); this.postList = temp; foreach (var post in postList) { PostComponent comp = new PostComponent(); Debug.WriteLine(post.post_text.ToString()); System.Drawing.Image image = InstaDB.DownloadImageFromUrl(post.photopath.ToString().Trim()); comp.Title = post.post_text.ToString(); comp.PostImage = image; comp.Likes = post.likes; comp.Pid = post.postId; comp.By = followers.Find(u => u.userId == post.userId).username; Debug.WriteLine(post.userId + " " + comp.By); comps.Add(comp); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
public Comments(PostComponent comp) { this.comp = comp; InitializeComponent(); }