private void ValidaPergunta(ViewPergunta dados, List <string> erros)
        {
            Refute(dados.IdTema <= 0, "Informe o Tema da Pergunta.");
            Refute(dados.IdNivel <= 0, "Informe o Nível da Pergunta.");
            Refute(string.IsNullOrEmpty(dados.Pergunta), "Informe a Pergunta.");

            using (ctx = new JogoMasterEntities())
            {
                Nivel nivel = null;
                nivel = ctx.Niveis.Where(x => x.Id == dados.IdNivel)
                        .FirstOrDefault();
                Refute(nivel == null, "Nível inexistente.");

                Tema tema = null;
                tema = ctx.Temas
                       .FirstOrDefault(x => x.Id == dados.IdTema);
                Refute(tema == null, "Tema inexistente.");

                Pergunta pergunta = null;
                pergunta = ctx.Perguntas
                           .Where(x => x.Pergunta1.ToLower() == dados.Pergunta.ToLower())
                           .FirstOrDefault();
                Refute(pergunta != null, $"Pergunta já cadastrada \"{ pergunta?.Pergunta1}\".");
            }
        }
        public IHttpActionResult Get(int id)
        {
            ViewPergunta         pergunta  = null;
            List <ViewResposta>  respostas = null;
            ViewPerguntaResposta retorno   = null;

            using (ctx = new JogoMasterEntities())
            {
                pergunta = ctx.Perguntas
                           .Where(x => x.Id == id).Select(s => new ViewPergunta()
                {
                    Id          = s.Id,
                    Pergunta    = s.Pergunta1,
                    IdNivel     = s.IdNivel,
                    IdTema      = s.IdTema,
                    Patrocinada = s.Patrocinada
                }).FirstOrDefault();

                if (pergunta == null)
                {
                    return(NotFound());
                }

                respostas = ctx.Respostas
                            .Where(s => s.IdPergunta == pergunta.Id)
                            .Select(s => new ViewResposta()
                {
                    Id         = s.Id,
                    Correta    = s.Correta,
                    Resposta   = s.Resposta1,
                    IdPergunta = s.IdPergunta
                })
                            .ToList();

                retorno = new ViewPerguntaResposta
                {
                    pergunta  = pergunta,
                    respostas = respostas
                };
            }

            return(Ok(retorno));
        }