예제 #1
0
        public ActionResult Compila(int id, FormCollection formCollection)
        {
            //Prendo tutti i valori dei radiobutton (filtro per quelli che iniziano con 'c')
            var form = formCollection.AllKeys.Where(k=> k.StartsWith("c")).ToDictionary(k => k, v => formCollection[v]);

            List<Answer> risposte = new List<Answer>();
            //salva risposte
            foreach (var coppia in form)
            {
                Answer answer = new Answer();
                string strQuestion = coppia.Key.Substring(1); //salto la 'c' (messa sul cshtml come prefisso per l'id)
                answer.DomandaId = Convert.ToInt32(strQuestion);
                
                string strSubQuestion = coppia.Value;
                answer.RispostaDataId = Convert.ToInt32(strSubQuestion);
                
                risposte.Add(answer);
            }

            surveyService.SalvaSurvey(id, User.Identity.Name, risposte);

            logger.Write(string.Format("L'utente {0} ha compilato il questionario", User.Identity.Name));
            return RedirectToAction("Success");
        }
예제 #2
0
        public ActionResult Revisiona(int id, FormCollection formCollection)
        {
            var form = formCollection.AllKeys.ToDictionary(k => k, v => formCollection[v]);

            List<Answer> risposte = new List<Answer>();
            //salva risposte
            foreach (var coppia in form)
            {
                Answer answer = new Answer();
                string strQuestion = coppia.Key.Substring(1); //salto la c
                answer.DomandaId = Convert.ToInt32(strQuestion);

                string strSubQuestion = coppia.Value;
                answer.RispostaDataId = Convert.ToInt32(strSubQuestion);

                risposte.Add(answer);
            }

            surveyService.SalvaSurveyRevisionato(id, risposte);

            logger.Write(string.Format("L'utente {0} ha revisionato il questionario", User.Identity.Name));

            return RedirectToAction("Success");
        }