adding more stuff
This commit is contained in:
parent
e00cabb840
commit
146495c07b
@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.VisualBasic;
|
||||
using OpenCand.API.Model;
|
||||
using OpenCand.API.Services;
|
||||
using OpenCand.Core.Models;
|
||||
@ -37,5 +38,14 @@ namespace OpenCand.API.Controllers
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,4 +16,9 @@ namespace OpenCand.API.Model
|
||||
{
|
||||
public List<RedeSocial> RedesSociais { get; set; }
|
||||
}
|
||||
|
||||
public class CpfRevealResult
|
||||
{
|
||||
public string Cpf { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -25,4 +25,10 @@
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="fotos_cand.zip" />
|
||||
<Content Remove="fotos_cand" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
</Project>
|
||||
|
@ -36,6 +36,17 @@ namespace OpenCand.Repository
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<string?> GetCandidatoCpfAsync(Guid idcandidato)
|
||||
{
|
||||
using (var connection = new NpgsqlConnection(ConnectionString))
|
||||
{
|
||||
return await connection.QueryFirstOrDefaultAsync<string>(@"
|
||||
SELECT cpf FROM candidato
|
||||
WHERE idcandidato = @idcandidato;",
|
||||
new { idcandidato });
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<CandidatoMapping>?> GetCandidatoMappingById(Guid idcandidato)
|
||||
{
|
||||
using (var connection = new NpgsqlConnection(ConnectionString))
|
||||
|
@ -94,5 +94,19 @@ namespace OpenCand.API.Services
|
||||
RedesSociais = result.OrderByDescending(r => r.Ano).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<CpfRevealResult> GetCandidatoCpfById(Guid idcandidato)
|
||||
{
|
||||
var result = await candidatoRepository.GetCandidatoCpfAsync(idcandidato);
|
||||
if (result == null)
|
||||
{
|
||||
return new CpfRevealResult();
|
||||
}
|
||||
|
||||
return new CpfRevealResult()
|
||||
{
|
||||
Cpf = result
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user