private async Task <PollReportPortugueseStudentResult> BuscarDadosPorTurmaAsync(ParametersModel parameters) { var BusinessPoll = new Data.Business.PollPortuguese(_config); var listaAlunosTurma = await BusinessPoll.BuscarAlunosTurmaRelatorioPortugues(parameters.CodigoTurmaEol, parameters.Proficiency, parameters.Term);//ajustar para pegar a turma List <PollReportPortugueseStudentItem> result = new List <PollReportPortugueseStudentItem>(); List <PortChartDataModel> graficos = new List <PortChartDataModel>(); foreach (var sondagem in listaAlunosTurma) { string tipo = ConverterProficienciaAluno(parameters.Proficiency, parameters.Term, sondagem); result.Add( new PollReportPortugueseStudentItem() { Code = sondagem.studentCodeEol, StudentName = sondagem.studentNameEol, StudentValue = tipo } ); graficos.Add(new PortChartDataModel() { Name = tipo, Value = 1 }); } PollReportPortugueseStudentResult retorno = new PollReportPortugueseStudentResult(); retorno.Results = result; var listaGrafico = graficos.GroupBy(fu => fu.Name).Select(g => new { Label = g.Key, Value = g.Count() }).ToList(); graficos = new List <PortChartDataModel>(); foreach (var item in listaGrafico) { graficos.Add(new PortChartDataModel() { Name = item.Label, Value = item.Value }); } retorno.ChartData = graficos; return(retorno); }
private async Task <PollReportPortugueseStudentResult> BuscarDadosPorTurmaAsync(ParametersModel parameters, Periodo periodo) { var BusinessPoll = new Data.Business.PollPortuguese(_config); var alunosBusiness = new AlunosBusiness(_config); var alunosEol = await alunosBusiness.ObterAlunosEOL(parameters.SchoolYear, parameters.CodigoTurmaEol, parameters.Term); var listaAlunosTurma = await BusinessPoll.BuscarAlunosTurmaRelatorioPortugues( parameters.CodigoTurmaEol, parameters.Proficiency, parameters.Term, periodo, Convert.ToInt32(parameters.SchoolYear), parameters.CodigoDRE, parameters.CodigoEscola, parameters.CodigoCurso);//ajustar para pegar a turma List <PollReportPortugueseStudentItem> result = new List <PollReportPortugueseStudentItem>(); List <PortChartDataModel> graficos = new List <PortChartDataModel>(); foreach (var aluno in alunosEol) { var sondagem = listaAlunosTurma.FirstOrDefault(s => s.studentCodeEol == aluno.CodigoAluno.ToString()); string tipo = ConverterProficienciaAluno(parameters.Proficiency, parameters.Term, sondagem); result.Add( new PollReportPortugueseStudentItem() { Code = aluno.CodigoAluno.ToString(), StudentName = aluno.NomeAlunoRelatorio, StudentValue = tipo } ); graficos.Add(new PortChartDataModel() { Name = tipo, Value = 1 }); } PollReportPortugueseStudentResult retorno = new PollReportPortugueseStudentResult(); retorno.Results = result; var listaGrafico = graficos.GroupBy(fu => fu.Name).Select(g => new { Label = g.Key, Value = g.Count() }).ToList(); graficos = new List <PortChartDataModel>(); foreach (var item in listaGrafico) { if (!string.IsNullOrWhiteSpace(item.Label)) { graficos.Add(new PortChartDataModel() { Name = item.Label, Value = item.Value }); } } retorno.ChartData = graficos.OrderBy(a => a.Name).ToList(); var semPreenchimento = listaGrafico.FirstOrDefault(a => string.IsNullOrWhiteSpace(a.Label)); if (semPreenchimento != null) { retorno.ChartData.Add(new PortChartDataModel() { Name = "Sem Preenchimento", Value = semPreenchimento.Value }); } return(retorno); }