private void Button2_Click(object sender, EventArgs e) { /*if (txtKULLANICI_ADI.Text.Trim() == "") * { * MessageBox.Show("Kullanıcı adı giriniz"); * return; * } * * if (txtSIFRESI.Text.Trim() == "") * { * MessageBox.Show("Şifre giriniz"); * return; * } * * if (txtDURUMU.Text.Trim() == "") * { * MessageBox.Show("Durumu giriniz"); * return; * }*/ // KAYDET if (txtYONETICI_REFNO.Text == "") // yeni kayit { YONETICI y = new YONETICI(); y.DURUMU = Convert.ToBoolean(txtDURUMU.Text); y.KULLANICI_ADI = txtKULLANICI_ADI.Text; y.SIFRESI = txtSIFRESI.Text; string jsonyonetici = JsonConvert.SerializeObject(y); HttpContent icerik = new StringContent(jsonyonetici, Encoding.UTF8, "application/json"); Task <HttpResponseMessage> response = client.PostAsync("http://localhost:51895/api/YONETICI", icerik); Task <string> sonuc = response.Result.Content.ReadAsStringAsync(); MessageBox.Show(sonuc.Result); } else // güncelle { YONETICI y = new YONETICI(); y.YONETICI_REFNO = Convert.ToInt32(txtYONETICI_REFNO.Text); y.DURUMU = Convert.ToBoolean(txtDURUMU.Text); y.KULLANICI_ADI = txtKULLANICI_ADI.Text; y.SIFRESI = txtSIFRESI.Text; string jsonyonetici = JsonConvert.SerializeObject(y); HttpContent icerik = new StringContent(jsonyonetici, Encoding.UTF8, "application/json"); Task <HttpResponseMessage> response = client.PutAsync("http://localhost:51895/api/YONETICI", icerik); Task <string> sonuc = response.Result.Content.ReadAsStringAsync(); MessageBox.Show(sonuc.Result); } YoneticiGetir(); }
void KayitGoster(string id) { Task <HttpResponseMessage> response = client.GetAsync("http://localhost:51895/api/YONETICI/" + id); Task <string> icerik = response.Result.Content.ReadAsStringAsync(); YONETICI y = JsonConvert.DeserializeObject <YONETICI>(icerik.Result); txtDURUMU.Text = Convert.ToString(y.DURUMU); txtKULLANICI_ADI.Text = y.KULLANICI_ADI; txtSIFRESI.Text = y.SIFRESI; txtYONETICI_REFNO.Text = Convert.ToString(y.YONETICI_REFNO); }