Example #1
0
 public Question(Guid courseId, Guid createdBy, string actualQuestion, LevelOfInterest levelOfInterest, Type type, decimal timeInMinutes = 0)
 {
     Id              = Guid.NewGuid();
     CourseId        = courseId;
     CreatedBy       = createdBy;
     ActualQuestion  = actualQuestion ?? throw new ArgumentNullException(nameof(actualQuestion));
     LevelOfInterest = levelOfInterest;
     Type            = type;
     DeadLine        = ComputeDeadLine(timeInMinutes);
     Answers         = new HashSet <Answer>();
 }
Example #2
0
        public ActionResult <IReadOnlyList <QuestionDto> > GetByLevelOfInterest(LevelOfInterest levelOfInterest)
        {
            IReadOnlyList <Question> questions = _readQuestionRepository.GetByLevelOfInterest(levelOfInterest);

            if (questions == null)
            {
                return(NotFound());
            }

            return(Ok(_mapper.EntityCollectionToDtoCollection(questions)));
        }
Example #3
0
 public IReadOnlyList <Question> GetByLevelOfInterest(LevelOfInterest levelOfInterest)
 {
     return(_context.Questions.Where(q => q.LevelOfInterest == levelOfInterest).ToList());
 }