コード例 #1
0
        // GET: /<controller>/
        public IActionResult Index()
        {
            QuestionRepository repo      = new QuestionRepository();
            List <AbQuestion>  questions = repo.GetAllQuestions();

            return(View(questions));
        }
コード例 #2
0
        public ActionResult GetAnswersByStudentId(int studentId)
        {
            var Answers = _answerRepository.GetAnswersByStudentId(studentId);

            _questionRepository.GetAllQuestions();

            return(Ok(Answers));
        }
コード例 #3
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"
         });
     }
 }
コード例 #4
0
        public QuestionModule()
        {
            IQuestionRepository repo = new QuestionRepository(ConfigurationManager.ConnectionStrings["happyIndex"].ConnectionString);

            Get["/api/questions"] = _ =>
            {
                var category = Request.Query.category;

                //filter the results if a category was supplied
                return(string.IsNullOrEmpty(category) ? repo.GetAllQuestions() : repo.GetByCategory(category));
            };

            Post["/api/questions"] = _ =>
            {
                var q = this.Bind <Question>();
                return(repo.Add(q.Text, q.Category));
            };
        }
コード例 #5
0
        public IActionResult Get()
        {
            IEnumerable <Entity_Question> questions     = _questionRepository.GetAllQuestions();
            List <QuestionDto>            questionsDtos = new List <QuestionDto>();

            if (!questions.Any())
            {
                return(BadRequest());
            }

            foreach (Entity_Question question in questions)
            {
                questionsDtos.Add(new QuestionDto()
                {
                    Id      = question.Id,
                    Content = question.Content,
                    Type    = question.Type,
                    Replies = _replyRepository.GetRepliesForQuestion(question.Id, question.Type).ToArray()
                });
            }

            return(Json(questionsDtos));
        }
コード例 #6
0
        public JsonResult GetAll()
        {
            ICollection <Question> questions = _repo.GetAllQuestions();

            return(new JsonResult(questions));
        }
コード例 #7
0
        public ActionResult GetAllQuestions()
        {
            var questions = _questionRepository.GetAllQuestions();

            return(Ok(questions));
        }
コード例 #8
0
        public IActionResult Index()
        {
            var repos = new QuestionRepository(_connectionString);

            return(View(repos.GetAllQuestions()));
        }