private async void button4_Click(object sender, EventArgs e) { textBox1.Text = "Buscando"; Task <string> resultado = new ClienteAPI().Get("7"); string res = await resultado; textBox1.Text = res.Desserialize().Nome; }
private async void button3_Click(object sender, EventArgs e) { textBox1.Text = "Excluindo"; Task <string> resultado = new ClienteAPI().Delete(99); string res = await resultado; textBox1.Text = res; }
private async void button5_Click(object sender, EventArgs e) { textBox1.Text = "Buscando"; Task <string> resultado = new ClienteAPI().Get(""); string res = await resultado; List <ClienteAPI> lista = res.DesserializeList(); textBox1.Text = lista.Count.ToString(); dataGridView1.DataSource = lista; }
private async void button2_Click(object sender, EventArgs e) { textBox1.Text = "Alterando"; Task <string> resultado = new ClienteAPI() { Codigo = 99, Nome = DateTime.Now.Millisecond.ToString(), DataCadastro = DateTime.Now.ToUniversalTime(), Tipo = 7 }.Put(99); string res = await resultado; textBox1.Text = res; }
private async void button1_Click(object sender, EventArgs e) { textBox1.Text = "Inserindo"; Task <string> resultado = new ClienteAPI() { Codigo = 99, Nome = "Mariana", DataCadastro = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day), Tipo = 7 }.Post(); string res = await resultado; textBox1.Text = res; }
public static string Serialize(this ClienteAPI obj) { MemoryStream stream1 = new MemoryStream(); DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(ClienteAPI)); ser.WriteObject(stream1, obj); stream1.Position = 0; StreamReader sr = new StreamReader(stream1); string x = sr.ReadToEnd(); return(x); }