I have a windows forms application that when a form loads, the web API retrieves data and sends it to the form. I have 2 GET functions in the API but I don't know how to call the 2nd one. Only the 1st one is called.
Below is the code of the click event and the API code.
So what should I do in the windows forms function to tell the program that I want to use the other function instead of the first?
Windows forms code:
private void ACombo_KeyDown(object sender, KeyEventArgs e) { LoadCombo(); } private async void LoadCombo() //populate combobox onLoad { using (var client = new HttpClient()) { using (var response = await client.GetAsync(URI)) { if (response.IsSuccessStatusCode) { var productJsonString = await response.Content.ReadAsStringAsync(); ACombo.BeginUpdate(); table = JsonConvert.DeserializeObject<DataTable>(productJsonString); for (int i = 0; i < table.Rows.Count; i++) { ACombo.Items.Add(table.Rows[i].ItemArray[0]); } ACombo.EndUpdate(); } } } }
And here's the API functions(Both in one controller):
public DataTable getX() { DataTable table = new DataTable(); string query = "SELECT <anything> FROM X"; //just as an example table= DAL.dynamiccommection(query, "contsh_conmam"); return table; } //2nd function public DataTable getY() { DataTable table = new DataTable(); string query = "SELECT <anything> FROM Y"; //just as an example table= DAL.dynamiccommection(query, "contsh_conmam"); return table; }