You need to create a controller for your domain object:
Apiversion = Version of your API
Route = Route to access your controller by url
Httpget = You define that your method will be the GET verb of the HTTP request. The parameter that I pass to the attribute ("searchFotosMesCurrent/{code}") defines which url will be used to make the request. The keys are used to send a parameter to the server, in this case I am sending the installation code that is a string (because I am not setting the type). If you want to pass an integer parameter, you can pass as follows {identifier:int}. The name of the parameter in the HTTPGET attribute must be the same as in the method parameter.
using using Microsoft.AspNetCore.Mvc;
[ApiVersion("1.0")]
[Route("processamento/[controller]")]
public class FotoController : Controller
{
[HttpGet("buscarFotosMesCorrente/{codigo}")]
public async Task<IActionResult> BuscarFotosMesCorrente(string codigo)
{
var idEmpresa = base.IdEmpresa.Value;
var item = await _service.BuscarFotosMesCorrente(idEmpresa, codigo);
if (item == null)
return NotFound();
return Ok(item);
}
}
In the body of the method you implement the logic you want to perform in the call of this method, such as fetching the object in the database (as you reported in your question).
To call this method would be as follows
http:localhost:5000/processamento/Foto/buscarFotoMesCorrente/AI1
I don’t know if I understood your doubt as being easier than it really is, but this link here helps you? If you scroll a little, you will see that it teaches you how to make GET request, among other things.
– StatelessDev
Unfortunately it doesn’t help me. I wonder how I receive the parameters dynamically from my application front.
– Renicius Pagotto
Show the code, only with this information it is difficult to understand the scenario. But from what I could understand, you could use Viewmodels to reflect and make the validations and queries you want. Or even a more complex structure to implement the search route in your Controllers... depedende muito do cenário e do que você realmente deseja.
– Leandro Angelo