Ejemplo n.º 1
0
        public EncuestaGeneralResponse ObtenerEncuestaParaResponder(int encuestaId)
        {
            EncuestaGeneral         e        = _contextoGeneral.EncuestaGeneral.SingleOrDefault(x => x.Id == encuestaId);
            EncuestaGeneralResponse encuesta = new EncuestaGeneralResponse()
            {
                Id           = e.Id,
                Nombre       = e.Titulo,
                LstPreguntas = new List <PreguntasResponse>()
            };
            List <PreguntasGeneral> preguntas = _contextoGeneral.PreguntasGeneral.Where(x => x.EncuestaGeneralId == encuesta.Id).ToList();

            foreach (var p in preguntas)
            {
                PreguntasResponse pregunta = new PreguntasResponse()
                {
                    Id           = p.Id,
                    Pregunta     = p.Frase,
                    TipoPregunta = p.TipoCheck,
                    LstOpciones  = new List <OpcionesResponse>()
                };
                encuesta.LstPreguntas.Add(pregunta);

                var respuestas = _contextoGeneral.OpcionesGeneral.Where(x => x.PreguntaGeneralId == p.Id).ToList();
                foreach (var resp in respuestas)
                {
                    pregunta.LstOpciones.Add(new OpcionesResponse()
                    {
                        Id        = resp.Id,
                        Respuesta = resp.Respuesta
                    });
                }
            }

            return(encuesta);
        }
Ejemplo n.º 2
0
        public List <EncuestaGeneralResponse> ObtenerEncuestas()
        {
            List <EncuestaGeneralResponse> lstEncResp = new List <EncuestaGeneralResponse>();
            var encuestas = _contextoGeneral.EncuestaGeneral.ToList();

            foreach (var e in encuestas)
            {
                var enc  = _contextoGeneral.EncuestaGeneral.SingleOrDefault(x => x.Id == e.Id);
                var encr = new EncuestaGeneralResponse()
                {
                    Id     = enc.Id,
                    Nombre = enc.Titulo
                };
                lstEncResp.Add(encr);
            }
            return(lstEncResp);
        }