For now I have a procedure I wish to call:
CALL Get_Discharge_Station('2022-02-02', 6, 11800);
I want to pass these three parameters - 2022-02-02,6,11800 to url address, when I enter different date,number and number of station to get different data.
For now my API controller look like this:
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
namespace WebAPI.Controllers
{
[Route("api/hqdataahs")]
[ApiController]
public class HQ_data_AHSController : ControllerBase
{
private readonly IConfiguration _configuration;
public HQ_data_AHSController(IConfiguration configuration)
{
_configuration = configuration;
}
[HttpGet]
public JsonResult Get()
{
string query = @"CALL Get_Discharge_Station('2022-02-02', 6, 11800);";
DataTable table = new DataTable();
string sqlDataSource = _configuration.GetConnectionString("AppCon");
MySqlDataReader myReader;
using (MySqlConnection mycon = new MySqlConnection(sqlDataSource))
{
mycon.Open();
using (MySqlCommand myCommand = new MySqlCommand(query, mycon))
{
myReader = myCommand.ExecuteReader();
table.Load(myReader);
myReader.Close();
mycon.Close();
}
}
return new JsonResult(table);
}
}
}
What can I change to pass there three parameters in url address when I access the controller?`