Exemple #1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        HttpClient client = NitsAPI.apiConnection();

        HttpResponseMessage response = client.GetAsync("imran").Result;


        ImranData imr = new ImranData();

        imr.Name    = txtname.Text;
        imr.Address = txtaddress.Text;
        imr.Phone   = txtphone.Text;

        var x = client.PostAsJsonAsync("imran", imr).Result;

        if (response.IsSuccessStatusCode)
        {
            ImranData ds   = new ImranData();
            var       data = response.Content.ReadAsAsync <IEnumerable <ImranData> >().Result;


            GridView1.DataSource = data;
            GridView1.DataBind();

            loaddata();
            txtname.Text    = "";
            txtaddress.Text = "";
            txtphone.Text   = "";
        }
        else
        {
            GridView1.DataSource = null;
            GridView1.DataBind();
        }
    }
Exemple #2
0
    protected void update_Click(object sender, EventArgs e)
    {
        HttpClient client = NitsAPI.apiConnection();

        HttpResponseMessage response = client.GetAsync("imran").Result;
        ImranData           imr      = new ImranData();

        imr.ID      = Convert.ToInt64(Session["dd"].ToString());
        imr.Name    = txtname.Text;
        imr.Address = txtaddress.Text;
        imr.Phone   = txtphone.Text;


        var x = client.PutAsJsonAsync("imran", imr).Result;

        if (response.IsSuccessStatusCode)
        {
            GridView1.DataSource = null;
            GridView1.DataBind();
            loaddata();
            txtname.Text    = "";
            txtaddress.Text = "";
            txtphone.Text   = "";
        }

        else
        {
            //Label1.Text = "not updated";
        }
    }