Пример #1
0
        private async void Mapear(Resultado reg, IniciaResultadoDto dto)
        {
            var consulta = await _repConsulta.GetConsultaAlunoAsyncById(dto.hashSimulacao);

            if (consulta == null)
            {
                throw new Exception("Erro ao carregar consulta código :" + dto.hashSimulacao);
            }

            reg.DataHora          = DateTime.Now;
            reg.AlunoId           = dto.AlunoId;
            reg.NomeAluno         = _repUser.GetUserById(dto.AlunoId).Result.FullName;
            reg.ProfessorId       = consulta.UserId;
            reg.NomeProfessor     = _repUser.GetUserById(reg.ProfessorId).Result.FullName;
            reg.HashLib           = dto.hashSimulacao;
            reg.PercAcertPergunta = 0;
            reg.PercAcertExame    = 0;
            reg.Finalizado        = false;
            reg.NomePaciente      = consulta.NomePaciente;
            reg.DataNascimento    = consulta.DataNascimento.ToString();
            reg.Sexo            = consulta.Sexo;
            reg.TipoAtendimento = consulta.TipoAtendimento;
            reg.QueixaPrincipal = consulta.QueixaPrincipal;
            reg.InicioSintomas  = consulta.InicioSintomas;
            reg.QtdMaxExame     = consulta.QtdMaxExame;
            reg.QtdMaxPergunta  = consulta.QtdMaxPergunta;

            reg.PerguntaRespostasResultados = new List <PerguntaRespostaResultado>();
            reg.ExameResultados             = new List <ExameResultado>();

            if (consulta.PerguntaRespostas.Any())
            {
                consulta.PerguntaRespostas.ForEach(pergResp =>
                {
                    reg.PerguntaRespostasResultados.Add(new PerguntaRespostaResultado
                    {
                        Pergunta    = pergResp.Pergunta,
                        Resposta    = pergResp.Resposta,
                        Certa       = pergResp.Certa,
                        Selecionada = false
                    });
                });
            }

            if (consulta.Exames.Any())
            {
                consulta.Exames.ForEach(exame =>
                {
                    var exameResult = new ExameResultado
                    {
                        Nome        = exame.Nome,
                        ImgExame    = exame.ImgExame,
                        Certa       = exame.Certa,
                        Selecionada = false
                    };

                    reg.ExameResultados.Add(exameResult);
                });
            }
        }
Пример #2
0
 public async Task <IActionResult> Post(IniciaResultadoDto dto)
 {
     try
     {
         var ret     = _aplicResultado.IniciaResultado(dto);
         var retorno = _mapper.Map <ResultadoView>(ret.Result);
         return(Ok(retorno));
     }
     catch (Exception ex)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, ex));
     }
 }
Пример #3
0
        public async Task <Resultado> IniciaResultado(IniciaResultadoDto dto)
        {
            var resultadoExistente = await _repResultado.GetResultado(dto.AlunoId, dto.hashSimulacao);

            if (resultadoExistente != null)
            {
                if (resultadoExistente.Finalizado)
                {
                    throw new Exception("Essa simulação já foi feita pelo aluno logado.");
                }

                return(resultadoExistente);
            }

            var resultado = new Resultado();

            Mapear(resultado, dto);

            _repResultado.Add(resultado);

            await _repResultado.SaveChangesAsync();

            return(resultado);
        }