Exemple #1
0
        public async Task <RetornoInfoPerfilDTO> GetProfileEmployeeInformation(string codeRF, string codeOccupations, string schoolYear, Guid?Perfil, string roleName = null)
        {
            try
            {
                var endPoint   = new EndpointsAPI();
                var profileApi = new PerfilSgpAPI(endPoint);
                var parseado   = int.TryParse(codeOccupations, out int result);

                var profileInformation = new RetornoInfoPerfilDTO();

                // Para coordenador pedagógico, assitente de diretor, diretor busca a abrangência no SGP
                if (!string.IsNullOrWhiteSpace(roleName) && (roleName.Equals("CP") || roleName.Equals("AD") || roleName.Equals("Diretor")))
                {
                    profileInformation = await ObterAbrangencia(codeRF, null, profileInformation);
                }
                else
                {
                    profileInformation = await profileApi
                                         .getInformacoesPerfil(codeRF, parseado?result : 0, int.Parse(schoolYear), _token, Perfil);
                }

                if (profileInformation != null)
                {
                    return(profileInformation);
                }
                else
                {
                    return(null);
                }
            }
            catch (System.Exception ex)
            {
                return(null);
            }
        }
Exemple #2
0
        private async Task <ActionResult> ObterProfileEmployeeInformationSME(BuscaPerfilServidor occupationsProfile, Perfil perfilSelecionado)
        {
            var createToken = new CreateToken(_config);
            var _token      = createToken.CreateTokenProvisorio();

            var abrangencia = await _AbrangenciaAPI.AbrangenciaCompactaSondagem(_token, occupationsProfile.codigoRF, perfilSelecionado.PerfilGuid);

            var retorno = new RetornoInfoPerfilDTO
            {
                DREs = abrangencia.Dres.Where(x => abrangencia.Ues.Any(z => z.CodigoDRE.Equals(x.CodigoDRE)))
                       .Select(x => new RetornoDREDTO
                {
                    Codigo = x.CodigoDRE,
                    Nome   = x.NomeDRE,
                    Sigla  = x.SiglaDRE
                }).ToHashSet(),
                CodigoServidor = occupationsProfile.codigoRF,
                Escolas        = abrangencia.Ues.Where(x => abrangencia.Turmas.Any(z => z.CodigoEscola.Equals(x.Codigo)))
                                 .Select(x => new RetornoEscolaDTO
                {
                    Sigla     = x.Sigla,
                    Codigo    = x.Codigo,
                    CodigoDRE = x.CodigoDRE,
                    Nome      = x.Nome
                }).ToHashSet()
            };

            return(Ok(retorno));
        }
Exemple #3
0
        private async Task <RetornoInfoPerfilDTO> ObterAbrangencia(string codeRF, int?schoolYear, RetornoInfoPerfilDTO profileInformation)
        {
            var novoSgpApi = new NovoSGPAPI();
            var dres       = await novoSgpApi.AbrangenciaDres(codeRF, schoolYear);

            dres.ForEach(dre =>
            {
                profileInformation.DREs.Add(new RetornoDREDTO()
                {
                    Codigo = dre.Codigo,
                    Nome   = dre.Nome,
                    Sigla  = dre.Abreviacao
                });
                var ues = novoSgpApi.AbrangenciaUes(codeRF, schoolYear, dre.Codigo).Result;
                ues.ForEach(ue => profileInformation.Escolas.Add(new RetornoEscolaDTO()
                {
                    Codigo    = ue.Codigo,
                    CodigoDRE = dre.Codigo,
                    Nome      = ue.Nome,
                    Sigla     = ue.NomeSimples
                }));
            });

            return(profileInformation);
        }