public static async Task <string> deleteProduto(int id) { var produto = new ProdutoCreateModel(); produto.id = id; using (HttpResponseMessage response = await ApiHelper.ApiClient.DeleteAsync($"{ApiHelper.baseUrl}/produto?id={produto.id}")) { if (response.IsSuccessStatusCode) { return("OK"); } else { throw new Exception(response.ReasonPhrase); } } }
public static async Task <string> estoqueProduto(int id, int estoque) { var produto = new ProdutoCreateModel(); produto.id = id; produto.estoque = estoque; var json = JsonConvert.SerializeObject(produto); var data = new StringContent(json, Encoding.UTF8, "application/json"); using (HttpResponseMessage response = await ApiHelper.ApiClient.PutAsync($"{ApiHelper.baseUrl}/produto/estoque", data)) { if (response.IsSuccessStatusCode) { return("OK"); } else { throw new Exception(response.ReasonPhrase); } } }
public static async Task <string> createProduto(string nome, float preco, int estoque, string tipo) { var produto = new ProdutoCreateModel(); produto.nome = nome; produto.preco = preco; produto.estoque = estoque; produto.tipo = tipo; var json = JsonConvert.SerializeObject(produto); var data = new StringContent(json, Encoding.UTF8, "application/json"); using (HttpResponseMessage response = await ApiHelper.ApiClient.PostAsync($"{ApiHelper.baseUrl}/produto", data)) { if (response.IsSuccessStatusCode) { return("OK"); } else { throw new Exception(response.ReasonPhrase); } } }