public ActionResult Revisiona(int id) { SurveyWithAnswers surveyWithAnswers = surveyService.GetSurveyWithAnswers(id); if (surveyWithAnswers != null) { return(View(surveyWithAnswers)); } else { throw new Exception("Survey Session non trovata"); } }
public SurveyWithAnswers GetSurveyWithAnswers(int idSurveySession) { SurveySession surveySession = GetSurveySession(idSurveySession); if (surveySession != null) { Survey survey = surveySession.Survey; List <Answer> risposte = surveySession.Risposte.ToList(); //Prendo tutte le domande e risposte var qWr = from q in survey.Questions let risposta = risposte.Single(r => r.DomandaId == q.Id) select new QuestionWithAnswer { RispostaDataId = risposta.RispostaDataId, Question = q }; //Carico le informazioni sul profilo string username = surveySession.User; UserProfile profilo = userService.GetUtente(username); //Creo l'oggetto per la view SurveyWithAnswers surveyWithAnswers = new SurveyWithAnswers { SurveySession = surveySession, DomandeConRisposte = qWr.ToList(), NomeRisorsa = profilo.ToString() }; return(surveyWithAnswers); } else { return(null); } }