/// <summary> /// Get quiz's questions. /// </summary> /// <returns>A List of DisplayQuestionModel.</returns> public async Task <List <DisplayQuestionModel> > GetQuestions() { QuestionData questionData = new QuestionData(_db); List <DisplayQuestionModel> questionModels = new List <DisplayQuestionModel>(); List <DataQuestionModel> dataQuestionModels = await questionData.GetQuestions(); foreach (var dataQuestionModel in dataQuestionModels) { DisplayQuestionModel newDisplayQuestionModel = new DisplayQuestionModel { DomainId = dataQuestionModel.DomainId, Id = dataQuestionModel.Id, Question = dataQuestionModel.Question, QuestionTypeId = dataQuestionModel.QuestionTypeId, }; if (!DisplayLinks.Any(x => x.QuestionId == dataQuestionModel.Id)) { // Les questions non ajoutées sont ajoutées dans la liste déroulante questionModels.Add(newDisplayQuestionModel); } else { // Les questions déjà liées sont affichées dans le tableau DisplayQuestions.Add(newDisplayQuestionModel); } } return(questionModels); }
/// <summary> /// Gets all questions and display them. /// </summary> public async Task OnGetAsync() { Domains = new SelectList(await GetDomains(), "Id", "Domain"); QuestionTypes = new SelectList(await GetQuestionTypes(), "Id", "QuestionType"); List <DisplayQuestionModel> questionModels = new List <DisplayQuestionModel>(); QuestionData questionData = new QuestionData(_db); List <DataQuestionModel> dataAccessQuestionModels = await questionData.GetQuestions(); foreach (DataQuestionModel dataAccessQuestionModel in dataAccessQuestionModels) { questionModels.Add(new DisplayQuestionModel { Question = dataAccessQuestionModel.Question, Id = dataAccessQuestionModel.Id, DomainId = dataAccessQuestionModel.DomainId, QuestionTypeId = dataAccessQuestionModel.QuestionTypeId, }); } Questions = questionModels; }
public ActionResult GeneralKnowledge(int?page, string txtSearch) { if (!user.IsManager()) { return(View("Error")); } else { if (page == null) { page = 1; } var cur = qdata.GetQuestions().Where(b => b.TypeID.Equals(1)).OrderBy(x => x.QuestionID); int pageSize = 10; int pageNumber = (page ?? 1); if (!String.IsNullOrEmpty(txtSearch)) { cur = qdata.GetQuestions().Where(b => b.TypeID.Equals(1) && b.QuestionDetails.ToUpper().Contains(txtSearch.ToUpper())).OrderBy(x => x.QuestionID); } return(View(cur.ToPagedList(pageNumber, pageSize))); } }