I have the following action in my Web Api controller:
[HttpPost]
[Route("api/geom")]
public HttpResponseMessage AddRef([FromBody]Peticion empObj)
{
using (SqlConnection con = new SqlConnection("Server=xx;database=xx;User Id=xx;Password=xx"))
{
string query = "UPDATE [dbo].[tmp_parcelas] SET[geom] = geometry::STGeomFromText('" + empObj.geom + "',25830) WHERE[idparcela] = " + empObj.id + ";";
using (SqlCommand querySaveStaff = new SqlCommand(query))
{
querySaveStaff.Connection = con;
con.Open();
querySaveStaff.ExecuteNonQuery();
con.Close();
}
}
return Request.CreateResponse(HttpStatusCode.OK);
}
It receives a lot of requests in a very short period of time (like 60 in 1 second or so), so I guess it is necessary to make the method asynchronous.
How can I make the controller action run asynchronously?
Thanks in advance.