/// <summary> /// Get question's answers. /// </summary> /// <returns>A List of DisplayAnswerModel.</returns> public async Task <List <DisplayAnswerModel> > GetAnswers() { AnswerData answerData = new AnswerData(_db); List <DisplayAnswerModel> answerModels = new List <DisplayAnswerModel>(); List <DataAnswerModel> dataAnswerModels = await answerData.GetAnswers(); foreach (var dataAnswerModel in dataAnswerModels) { DisplayAnswerModel newDisplayAnswerModel = new DisplayAnswerModel { Answer = dataAnswerModel.Answer, Id = dataAnswerModel.Id, PlayerAnswer = dataAnswerModel.PlayerAnswer, Type = dataAnswerModel.Type, }; if (!DisplayLinks.Any(x => x.AnswerId == dataAnswerModel.Id)) { // Unadded questions are added to the dropdown answerModels.Add(newDisplayAnswerModel); } else { // Already linked questions are displayed in the table DisplayAnswers.Add(newDisplayAnswerModel); } } return(answerModels); }
/// <summary> /// Gets the answers and display them. /// </summary> public async Task OnGetAsync() { List <DisplayAnswerModel> answerModels = new List <DisplayAnswerModel>(); AnswerData answerData = new AnswerData(_db); List <DataAnswerModel> dataAccessAnswerModels = await answerData.GetAnswers(); foreach (DataAnswerModel dataAccessAnswerModel in dataAccessAnswerModels) { answerModels.Add(new DisplayAnswerModel { Answer = dataAccessAnswerModel.Answer, Id = dataAccessAnswerModel.Id, PlayerAnswer = dataAccessAnswerModel.PlayerAnswer, Type = dataAccessAnswerModel.Type, }); } Answers = answerModels; }