Ejemplo n.º 1
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            if (searchBox.Text != "")
            {
                var        userNick = searchBox.Text;
                HttpClient client   = new HttpClient();
                client.BaseAddress = new Uri(connectionString);
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                var url = "api/users/name/" + userNick;
                HttpResponseMessage response = client.GetAsync(url).Result;
                if (response.IsSuccessStatusCode)
                {
                    Users user = response.Content.ReadAsAsync <Users>().Result;
                    if (user.UserId == Guid.Empty)
                    {
                        MessageBox.Show("Пользователь не найден");
                    }
                    else
                    {
                        watchUser = user;
                        SomeUserPage frm = new SomeUserPage();
                        frm.Show();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri(connectionString);

            if (!tofollow)
            {
                client.DefaultRequestHeaders.Accept.Add(
                    new MediaTypeWithQualityHeaderValue("application/json"));
                //var response = client.PostAsJsonAsync("api/followers/" + Program.userId, UserPage.watchUser).Result;
                Users temp = new Users();
                temp.UserId = Program.userId;
                var response = client.PostAsJsonAsync("api/followers/" + UserPage.watchUser.UserId, temp).Result;
                if (response.IsSuccessStatusCode)
                {
                    subcribe.Text = "Отписаться";
                    tofollow      = true;
                }
                else
                {
                }
            }
            SomeUserPage frm = new SomeUserPage();

            this.Hide();
            frm.Show();
        }