opencand/OpenCand.API/Controllers/CandidatoController.cs
Jose Henrique 146495c07b
All checks were successful
API and ETL Build / build_etl (push) Successful in 2s
API and ETL Build / build_api (push) Successful in 14s
adding more stuff
2025-05-31 14:43:37 -03:00

52 lines
1.6 KiB
C#

using Microsoft.AspNetCore.Mvc;
using Microsoft.VisualBasic;
using OpenCand.API.Model;
using OpenCand.API.Services;
using OpenCand.Core.Models;
namespace OpenCand.API.Controllers
{
public class CandidatoController : BaseController
{
private readonly OpenCandService openCandService;
public CandidatoController(OpenCandService openCandService)
{
this.openCandService = openCandService;
}
[HttpGet("search")]
public async Task<CandidatoSearchResult> CandidatoSearch([FromQuery] string q)
{
return await openCandService.SearchCandidatosAsync(q);
}
[HttpGet("{id}")]
public async Task<Candidato> GetCandidatoById([FromRoute] Guid id)
{
return await openCandService.GetCandidatoAsync(id);
}
[HttpGet("{id}/bens")]
public async Task<BemCandidatoResult> GetBensCandidatoById([FromRoute] Guid id)
{
return await openCandService.GetBemCandidatoById(id);
}
[HttpGet("{id}/rede-social")]
public async Task<RedeSocialResult> GetCandidatoRedeSocialById([FromRoute] Guid id)
{
return await openCandService.GetCandidatoRedeSocialById(id);
}
[HttpGet("{id}/reveal-cpf")]
public async Task<CpfRevealResult> GetCandidatoCpfById([FromRoute] Guid id)
{
var rnd = new Random();
var randomWait = rnd.Next(1000, 3000);
await Task.Delay(randomWait);
return await openCandService.GetCandidatoCpfById(id);
}
}
}