Пример #1
0
 private void button2_Click(object sender, EventArgs e)
 {
     try
     {
         PInstaSR.IpostServiceClient client = new PInstaSR.IpostServiceClient();
         client.incrementLike(this.Likes.GetValueOrDefault(0), this.Pid);
         this.Likes++;
         label2.Text = this.Likes + "Likes";
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
     }
 }
        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);
            }
        }
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         string        description = textBox1.Text;
         string        link        = textBox2.Text;
         PInstaSR.Post post        = new PInstaSR.Post();
         post.userId        = InstaDB.user.userId;
         post.photopath     = link;
         post.location      = textBox3.Text;
         post.creation_date = DateTime.Now;
         post.post_text     = description;
         post.likes         = 0;
         PInstaSR.IpostServiceClient client = new PInstaSR.IpostServiceClient();
         client.createPost(post);
         label5.Text = "Posted your post";
     }
     catch (Exception ex)
     {
         Debug.Write(ex.Message);
     }
 }