Exemple #1
0
        public QuestionsSurvey StartSurvey(int userId, int surveyId, JoiningPlatform platform)
        {
            // Get the user survey record if exists.
            var userSurvey = _surveyRepository.GetUserSurvey(userId, surveyId);

            if (userSurvey == null)
            {
                userSurvey = new UserSurvey
                {
                    UserId          = userId,
                    SurveyId        = surveyId,
                    StartedOn       = DateTime.UtcNow,
                    PageCompleted   = 0,
                    JoiningPlatform = (int)platform
                };

                _surveyRepository.AddUserSurvey(userSurvey);
                _unitOfWork.Commit();
            }

            var data = new QuestionsSurvey();

            data.PageNum   = userSurvey.PageCompleted + 1;
            data.Questions = _surveyQuestionRepository.GetSurveyQuestions(surveyId, userId);

            return(data);
        }
Exemple #2
0
 public IEnumerable <DetailedQuestion> GetSurveyQuestions(int surveyId, int?userId)
 {
     return(_surveyQuestionRepository.GetSurveyQuestions(surveyId, userId));
 }