/// <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); }
public PlayPresenter(IPlayView view, IPlayRepository repository, Game game) { this.view = view; view.Presenter = this; this.repository = repository; this.game = game; switch (game.CategoryGuess) { case "flag": this.displayQuestion = new DisplayQuestion(displayQuestionAsFlag); break; case "capital": this.displayQuestion = new DisplayQuestion(displayQuestionAsCapital); break; default: this.displayQuestion = new DisplayQuestion(displayQuestionAsCountry); break; } switch (game.CategoryHint) { case "flag": this.displayAnswers = new DisplayAnswers(displayAnswersAsFlag); break; case "capital": this.displayAnswers = new DisplayAnswers(displayAnswersAsCapital); break; default: this.displayAnswers = new DisplayAnswers(displayAnswersAsCountry); break; } }