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));
        }
        public string[] GetCountOptions(ResultVote resultVote, ResultVote cvppt)
        {
            string[] arrayInt = new string[9];

            if (cvppt.a > 0 || resultVote.a > 0)
            {
                arrayInt[0] = (resultVote.a + cvppt.a).ToString();
            }
            if (cvppt.b > 0 || resultVote.b > 0)
            {
                arrayInt[1] = (resultVote.b + cvppt.b).ToString();
            }
            if (cvppt.c > 0 || resultVote.c > 0)
            {
                arrayInt[2] = (resultVote.c + cvppt.c).ToString();
            }
            if (cvppt.d > 0 || resultVote.d > 0)
            {
                arrayInt[3] = (resultVote.d + cvppt.d).ToString();
            }
            if (cvppt.e > 0 || resultVote.e > 0)
            {
                arrayInt[4] = (resultVote.e + cvppt.e).ToString();
            }
            if (cvppt.f > 0 || resultVote.f > 0)
            {
                arrayInt[5] = (resultVote.f + cvppt.f).ToString();
            }
            if (cvppt.g > 0 || resultVote.g > 0)
            {
                arrayInt[6] = (resultVote.g + cvppt.g).ToString();
            }
            if (cvppt.h > 0 || resultVote.h > 0)
            {
                arrayInt[7] = (resultVote.h + cvppt.h).ToString();
            }
            if (cvppt.i > 0 || resultVote.i > 0)
            {
                arrayInt[8] = (resultVote.i + cvppt.i).ToString();
            }
            if (cvppt.j > 0 || resultVote.j > 0)
            {
                arrayInt[9] = (resultVote.j + cvppt.j).ToString();
            }
            return(arrayInt);
        }
Exemplo n.º 3
0
        public ResultVote getVote(List <TB_Vote> votes)
        {
            ResultVote rv = new ResultVote();

            var qx = from n in votes select n;

            rv.a = (from x in qx where x.result.Contains('1') select x).Count();
            rv.b = (from x in qx where x.result.Contains('2') select x).Count();
            rv.c = (from x in qx where x.result.Contains('3') select x).Count();
            rv.d = (from x in qx where x.result.Contains('4') select x).Count();
            rv.e = (from x in qx where x.result.Contains('5') select x).Count();
            rv.f = (from x in qx where x.result.Contains('6') select x).Count();
            rv.g = (from x in qx where x.result.Contains('7') select x).Count();
            rv.h = (from x in qx where x.result.Contains('8') select x).Count();
            rv.i = (from x in qx where x.result.Contains('9') select x).Count();
            rv.j = (from x in qx where x.result.Contains('0') select x).Count();


            return(rv);
        }