using System.Collections.Generic; using System.Linq; namespace TINK.ViewModel.MiniSurvey.Question { public class CheckOneViewModel : IMiniSurveyQuestion { /// Constructs object. /// Holds the question with key asked to user. /// Holds the list of possible answers with their option keys. public CheckOneViewModel( KeyValuePair question, Dictionary answers) { Question = question; Answers = answers ?? new Dictionary(); } /// Holds the question with key asked to user. public KeyValuePair Question { get; } /// Holds the question with key asked to user exposed to GUI. public string QuestionText => Question.Value; /// Holds the list of possible answers with their option keys. public Dictionary Answers { get; } /// Holds the list of possible answers exposed to GUI. public IEnumerable AnswersText { get => Answers.Select(x => x.Value).ToList(); set => AnswersText = Answers.Select(x => x.Value).ToList(); } /// Holds the users selected answer (one of answers) with its option key. public KeyValuePair Answer { get; private set; } /// Holds the users selected answer (one of answers) in GUI. public string AnswerText { get => Answer.Value; set => Answer = Answers.FirstOrDefault(x => x.Value == value); } } }