Пример #1
0
 public QuestionCollectionEntity GetQuestions(User user)
 {
     try
     {
         List <UserQuestionAnswer> userQuestions = null;
         if (user != null)
         {
             userQuestions = userRepository.GetUserQuestions(user);
         }
         var allQuestions = questionRepository.GetAllQuestions();
         var questionList = new List <QuestionEntity>();
         foreach (var question in allQuestions)
         {
             var newQuestion = new QuestionEntity()
             {
                 questionId          = question.Id,
                 questionText        = question.QuestionText,
                 questionType        = question.QuestionType,
                 questionRightAnswer = question.QuestionRightAnswer
             };
             if (user != null && userQuestions != null)
             {
                 newQuestion.userId = user.Id;
                 foreach (var userQuestion in userQuestions)
                 {
                     if (question.Id == userQuestion.QuestionId)
                     {
                         newQuestion.userAnswer = userQuestion.Answer;
                         newQuestion.Points     = userQuestion.Points;
                     }
                 }
             }
             questionList.Add(newQuestion);
         }
         var stages = stageRepository.GetAllStages();
         var teams  = teamRepository.GetAllTeams();
         return(new QuestionCollectionEntity()
         {
             questions = questionList, stages = stages, teams = teams
         });
     }
     catch (Exception ex)
     {
         return(new QuestionCollectionEntity()
         {
             Exception = ex.InnerException.Message, ErrorMsg = "Error in BetService Save the BEt"
         });
     }
 }
Пример #2
0
 public List <Stage> GetAllStages()
 {
     return(stageRepository.GetAllStages());
 }
Пример #3
0
 public IEnumerable <Stage> GetAllStages()
 => StageRepository.GetAllStages();