コード例 #1
0
        public async Task <IActionResult> GetCandidate([FromRoute] string digito)
        {
            var result = await repo.GetCandidatoByDigito(digito);

            var webRootPath = environment.WebRootPath;

            if (result == null)
            {
                return(NotFound(new { message = "Candidato não encontrado!" }));
            }

            var candidato = new CandidatoDto
            {
                Id            = result.Id,
                Digito        = result.Digito,
                DataRegistro  = result.DataRegistro,
                Legenda       = result.Legenda,
                NomeCompleto  = result.NomeCompleto,
                NomeVice      = result.NomeVice != null ?result.NomeVice : "",
                TipoCandidato = result.TipoCandidato,
                FotoCandidato = Utils.SearchFile($"{result.Digito}_", webRootPath),
                FotoVice      = result.NomeVice != null?Utils.SearchFile($"{result.Digito}_vice_", webRootPath) : "",
            };

            return(Ok(new { candidato }));
        }