public static SurveyResultsViewModel MapLatestResult(Survey survey,IRespondentRepository respondentRepository, IQuestionRepository questionRepository) { // Get the latest respondents answers. ICollection<Respondent> latestRespondents = new List<Respondent>(); latestRespondents.Add(respondentRepository.GetLatestResultForSurvey(survey.SurveyId)); // Instantiate the view model SurveyResultsViewModel surveyResults = new SurveyResultsViewModel(); // map the Survey information surveyResults.SurveyId = survey.SurveyId; surveyResults.Title = survey.Title; // Map the results information. surveyResults.Results = MapResponses(latestRespondents, questionRepository); return surveyResults; }
/// <summary> /// HomeController Constructor which injects the instance of the Domain Model Repositories. /// </summary> /// <param name="repository">Instance of the Domain Model Repository</param> public HomeController(ISurveyRepository surveyRepository, ICategoryRepository categoryRepository, IQuestionRepository questionRepository, IRespondentRepository respondentRepository , IMapTakeSurveyViewModel takeSurveyViewModeMapper, IReinstateTakeSurveyViewModel reinstateTakeSurveyViewModelMapper) { if (surveyRepository == null) throw new ArgumentNullException("repository", "No valid repository supplied to HomeController"); if (categoryRepository == null) throw new ArgumentNullException("CategoryRepository","No valid Category repository supplied to HomeController"); if (questionRepository == null) throw new ArgumentNullException("QuestionRepository", "No valid Question repository supplied to HomeController"); if (respondentRepository == null) throw new ArgumentNullException("RespondentRepository", "No valid Respondent repository supplied to HomeController"); if (takeSurveyViewModeMapper == null) throw new ArgumentNullException("TakeSurveyviewModelMapper", "No valid mapper for TakeSurveyViewModel supplied to HomeController"); if (reinstateTakeSurveyViewModelMapper == null) throw new ArgumentNullException("ReinstateTakeSurveyViewModelMapper", "No valie mapper for ReinstateTakeSurveyViewModel supplied to HomeController"); _surveyRepository = surveyRepository; _categoryRepository = categoryRepository; _questionRepository = questionRepository; _respondentRepository = respondentRepository; _takeSurveyViewModelMapper = takeSurveyViewModeMapper; _reinstateTakeWurveyViewModelMapper = reinstateTakeSurveyViewModelMapper; }
public SurveysController(ISurveyRepository surveyRepository, RespondentRepository respondentRepository) { this.surveyRepository = surveyRepository; this.respondentRepository = respondentRepository; }
public RespondentsController(IRespondentRepository respondentRepository) { this.respondentRepository = respondentRepository; }
public ResponsesController(IRespondentRepository respondentRepository, IResponseRepository responseRepository, ISurveyRepository surveyRepository) { this.respondentRepository = respondentRepository; this.responseRepository = responseRepository; this.surveyRepository = surveyRepository; }