public ActionResult <IEnumerable <QuestionsReadDto> > GetAllCommands(QuestionsReadDto questionsreaddto, int page) { var questionItems = _repository.GetAllQuestions(questionsreaddto, page); if (questionItems != null) { return(Ok(_mapper.Map <IEnumerable <QuestionsReadDto> >(questionItems))); } return(NotFound()); }
public IEnumerable <TblQuestions> GetAllQuestions(QuestionsReadDto questionsreaddto, int page) { IEnumerable <TblQuestions> result = _context.TblQuestions; if (questionsreaddto != null) { if (!string.IsNullOrEmpty(questionsreaddto.Difficulty)) { result = result.Where(x => x.Difficulty.Contains(questionsreaddto.Difficulty)); } if (!string.IsNullOrEmpty(questionsreaddto.Type)) { result = result.Where(x => x.Type.Contains(questionsreaddto.Type)); } if (!string.IsNullOrEmpty(questionsreaddto.QuestionTopic)) { result = result.Where(x => x.QuestionTopic.Contains(questionsreaddto.QuestionTopic)); } } return(result.Skip(page * 2).Take(2).ToList()); }