Пример #1
0
        public JsonResult getQuestions()
        {
            var userVote = (TB_UserVote)Session["UserVote"];

            ListVote      lv       = new ListVote();
            List <string> lsresult = new List <string>();

            int order = lv.getOrderQuestion(DBConnect.open(), userVote.votationid);

            TB_Votation_Questions _Questions = new TB_Votation_Questions();

            _Questions.votationId = userVote.votationid;
            _Questions.order      = order;


            TB_Votation_Questions qRequest = lv.getquestions(DBConnect.open(), _Questions);
            List <TB_Votation_Questions_Answer> lstanswer = lv.getAnswer(DBConnect.opentwo(), qRequest.id);

            lsresult.Add(qRequest.question);

            for (int e = 0; e < lstanswer.Count; e++)
            {
                lsresult.Add(lstanswer[e].answer.ToString());
            }

            return(Json(lsresult, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public JsonResult CreateVote(TB_Vote v)
        {
            var user = (TB_UserVote)Session["UserVote"];

            int order = lv.getOrderQuestion(DBConnect.open(), user.votationid);

            TB_Votation_Questions _Questions = new TB_Votation_Questions();

            _Questions.votationId = user.votationid;
            _Questions.order      = order;


            TB_Votation_Questions qRequest = lv.getquestions(DBConnect.open(), _Questions);

            Utils u = new Utils();

            v.userVoteid = user.id;
            v.votationid = user.votationid;
            v.mac        = getipUser();
            v.questionid = qRequest.id;
            TB_Vote_Data vdata  = new TB_Vote_Data();
            string       result = vdata.addVote(v, DBConnect.open());

            return(Json(result));
        }
        public JsonResult Report(string key)
        {
            string[] colors  = new string[9];
            string[] graphic = new string[] { };
            string[] options = new string[9];

            int      idf = int.Parse(key);
            ListVote lv  = new ListVote();

            List <ResultOptions> lstro = lv.getOptions(DBConnect.open(), idf);


            int order = lv.getOrderQuestion(DBConnect.open(), idf);

            TB_Votation_Questions _Questions = new TB_Votation_Questions();

            _Questions.votationId = idf;
            _Questions.order      = order;


            TB_Votation_Questions qRequest = lv.getquestions(DBConnect.open(), _Questions);
            List <TB_Vote>        votes    = lv.getListVote("max", idf, qRequest.id, DBConnect.open());

            List <TB_Votation_Questions_Answer> lstanswer = lv.getAnswer(DBConnect.open(), qRequest.id);

            graphic = new string[] { qRequest.question, lstro[0].graphic, lstro[0].height.ToString(), lstro[0].width.ToString(), lstro[0].imagefondo, lstro[0].visible };

            /*
             *          for (int i = 0; i < lstro.Count; i++)
             *          {
             *              colors[i] = lstro[i].color;
             *              options[i] = lstro[i].option;
             *          }
             */
            for (int i = 0; i < lstanswer.Count; i++)
            {
                colors[i]  = lstro[i].color;
                options[i] = lstanswer[i].answer;
            }
            ResultVote rv  = lv.getVote(votes);
            ResultVote rv2 = new ResultVote();

            string[] value   = GetCountOptions(rv, rv2);
            var      Tablero = new[] { graphic, colors, options, value };

            return(Json(Tablero, JsonRequestBehavior.AllowGet));
        }