public async System.Threading.Tasks.Task <IActionResult> RelatorioFinalAsync(int quizzId, int alunoId, string sessaoNome) { var result = _respostaService.GerarDadosRelatorio(quizzId, alunoId, sessaoNome); var sessao = _userManager.FindByNameAsync(sessaoNome).Result; result.NomeAluno = sessao.UserName; using (var client = new HttpClient()) { var vaisefuder = await client.PostAsJsonAsync("http://localhost:62626/PostRelatorio", result); var r = new FileContentResult(await vaisefuder.Content.ReadAsByteArrayAsync(), vaisefuder.Content.Headers.ContentType.MediaType); return(r); } }
public async System.Threading.Tasks.Task <IActionResult> RelatorioProfessor(int id) { var report = new List <RelatorioFinalObjectDTO>(); var perguntas = _PerguntaService.PerguntasByQuizzId(id).Select(x => x.PerguntaId); var alunos = (from A in _respostaService.GetAll() join B in _estudanteService.GetAll() on A.EstudanteId equals B.EstudanteId where perguntas.Contains(A.PerguntaId) select B).Distinct(); foreach (var item in alunos) { var result = _respostaService.GerarDadosRelatorio(id, item.EstudanteId, item.Nome); report.Add(result); } using (var client = new HttpClient()) { var teste = await client.PostAsJsonAsync("http://localhost:62626/Professor/RelatorioProfessor", report); var r = new FileContentResult(await teste.Content.ReadAsByteArrayAsync(), teste.Content.Headers.ContentType.MediaType); return(r); } }