public TriviaGameQuestionViewModel(TriviaGameQuestionModel model) { this.Question = model.Question; this.CorrectAnswer = model.CorrectAnswer; this.WrongAnswer1 = model.Answers[1]; this.WrongAnswer2 = (model.Answers.Count > 2) ? model.Answers[2] : string.Empty; this.WrongAnswer3 = (model.Answers.Count > 3) ? model.Answers[3] : string.Empty; }
public TriviaGameQuestionModel GetModel() { TriviaGameQuestionModel result = new TriviaGameQuestionModel() { Question = this.Question }; result.Answers.Add(this.CorrectAnswer); result.Answers.Add(this.WrongAnswer1); if (!string.IsNullOrEmpty(this.WrongAnswer2)) { result.Answers.Add(this.WrongAnswer2); } if (!string.IsNullOrEmpty(this.WrongAnswer3)) { result.Answers.Add(this.WrongAnswer3); } return(result); }