private async Task <Dictionary <string, string> > SetOccupationsRF(string rf, RetornoCargosServidorDTO occupations) { var ProfileBusiness = new Profile(_config); string roleName = ""; string accessLevel = ""; bool haveOccupationAccess; bool isTeacher = false; int qtdIsTeacher = 0; var ListcodeOcupations = new Dictionary <string, string>(); if (occupations != null) { //Implementar regra de cargo sobrePosto foreach (var occupation in occupations.cargos) { string codigoCargoAtivo = ProfileBusiness.RetornaCargoAtivo(occupation); haveOccupationAccess = false; switch (codigoCargoAtivo) { case "3239": case "3301": roleName = "Professor"; accessLevel = "32"; haveOccupationAccess = true; isTeacher = true; qtdIsTeacher += 1; break; case "3310": roleName = "Professor"; accessLevel = "32"; haveOccupationAccess = true; qtdIsTeacher += 1; break; case "3379": roleName = "CP"; accessLevel = "27"; haveOccupationAccess = true; break; case "3360": roleName = "Diretor"; accessLevel = "27"; haveOccupationAccess = true; break; case "3085": roleName = "AD"; accessLevel = "26"; haveOccupationAccess = true; break; default: haveOccupationAccess = false; break; } if (haveOccupationAccess) { try { if (isTeacher) { if (qtdIsTeacher == 1) { var profileBusiness = new Profile(_config); var profileInformation = await profileBusiness.GetProfileEmployeeInformation(rf, codigoCargoAtivo, DateTime.Now.Year.ToString(), default); if (profileInformation != null) { await Authentication.SetRole(rf, roleName, accessLevel, Perfil.ObterPerfis().FirstOrDefault(x => x.RoleName.Equals(roleName)).PerfilGuid); ListcodeOcupations.Add(roleName, codigoCargoAtivo); } } } else { await Authentication.SetRole(rf, roleName, accessLevel, Perfil.ObterPerfis().FirstOrDefault(x => x.RoleName.Equals(roleName)).PerfilGuid); ListcodeOcupations.Add(roleName, codigoCargoAtivo); } } catch (Exception ex) { throw ex; } //verifica se tem turma atribuida } } } return(ListcodeOcupations); }
private async Task <Dictionary <string, string> > SetOccupationsRF(string rf, RetornoCargosServidorDTO occupations) { var ProfileBusiness = new Profile(_config); string roleName = ""; string accessLevel = ""; bool haveOccupationAccess; bool isTeacher = false; var ListcodeOcupations = new Dictionary <string, string>(); if (occupations != null) { //Implementar regra de cargo sobrePosto foreach (var occupation in occupations.cargos) { string codigoCargoAtivo = ProfileBusiness.RetornaCargoAtivo(occupation); haveOccupationAccess = false; switch (codigoCargoAtivo) { case "3239": roleName = "Professor"; accessLevel = "32"; haveOccupationAccess = true; isTeacher = true; break; case "3301": roleName = "Professor"; accessLevel = "32"; haveOccupationAccess = true; isTeacher = true; break; case "3336": roleName = "Professor"; accessLevel = "32"; haveOccupationAccess = true; isTeacher = true; break; case "3310": roleName = "Professor"; accessLevel = "32"; haveOccupationAccess = true; isTeacher = true; break; case "3379": roleName = "CP"; accessLevel = "27"; haveOccupationAccess = true; break; case "3360": roleName = "Diretor"; accessLevel = "27"; haveOccupationAccess = true; break; default: haveOccupationAccess = false; break; } if (haveOccupationAccess) { try { if (isTeacher) { var profileBusiness = new Profile(_config); var profileInformation = await profileBusiness.GetProfileEmployeeInformation(rf, codigoCargoAtivo, "2019"); if (profileInformation != null) { await Authentication.SetRole(rf, roleName, accessLevel); ListcodeOcupations.Add(roleName, codigoCargoAtivo); } } else { await Authentication.SetRole(rf, roleName, accessLevel); ListcodeOcupations.Add(roleName, codigoCargoAtivo); } } catch (Exception ex) { throw ex; } //verifica se tem turma atribuida } } } return(ListcodeOcupations); }