// Constructors public AnswerVM() { answer = new Answer(); }
public AnswerVM(Answer a) { answer = a; }
public void AddAnswer() { if (AnswerList.Count < 4) { if (AnswerText.Trim().Length > 0) { Answer answer = new Answer(); answer.QuestionId = Id; answer.Text = AnswerText; answer.IsCorrect = false; answer = MainViewModel.context.Answer.Add(answer); MainViewModel.context.SaveChanges(); AnswerList.Add(new AnswerVM(answer)); RaisePropertyChanged("AnswerList"); RaisePropertyChanged("AmountOfQuestions"); } else { System.Windows.MessageBox.Show("Enter an answer"); } } }