You need to create a controller for your domain object:
ApiVersion = Your API Version
Route = Route to access your controller via the url
HttpGet = You define that your method will be the GET verb of the HTTP request. The parameter that I pass to the attribute ("searchFotosMesCorrente / {code}") defines which url will be used to make the request. The keys are used to send a parameter to the server, in which case I am sending the installation code which is a string (since I am not defining the type). If you want to pass an integer parameter, you can pass as {identifier: int}. The parameter name in the HTTPGET attribute should be the same as 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 entered in your question).
To call this method would look like this
http:localhost:5000/processamento/Foto/buscarFotoMesCorrente/AI1