public void PopulateAnswerList() { var APVM = new List <AnswerPictureViewModel>(); List <Answer> answers = answerRepo.GetAnswers(); foreach (var a in answers) { var add = new AnswerPictureViewModel(); add.Text = a.Text; //if answer has an image if (a.AnswerPictures.Count != 0) { //gets image and adds it to the view model var p = a.AnswerPictures.ToList(); Picture picture = picRepo.GetPicture(p[0].PictureID); add.Image = imageConverter.ByteToImage(picture.Image); } else { add.Image = null; } APVM.Add(add); } AnswerList.ItemsSource = APVM; }
public void PopulateModelAnswerList() { //if question has images if (selected.OptionsText != null && selected.AnswerText != null && selected.ImageIDs != "") { //Splits question's details in their own list var options = selected.OptionsText.Split('|'); var possibleAnswers = selected.AnswerText.Split('|'); var images = selected.ImageIDs.Split('|'); //Loop through possible answers for (int i = 0; i < options.Length; i++) { //place them in holder and set variables QuestAnsViewModel t = new QuestAnsViewModel(); t.Text = options[i]; t.Index = i; //If possible answer is in correct answer, checkbox to true if (possibleAnswers.Contains(options[i])) { t.IsTrue = true; } if (images[i] != "0") { //gets the image for the question and puts it in the view model Picture pic = picRepo.GetPicture(Convert.ToInt32(images[i])); t.Image = imageConverter.ByteToImage(pic.Image); t.ImageID = images[i]; } display.Add(t); } } //if question doesn't have images else if (selected.OptionsText != null && selected.AnswerText != null) { //Splits question's details in their own list var options = selected.OptionsText.Split('|'); var possibleAnswers = selected.AnswerText.Split('|'); //Loop through possible answers for (int i = 0; i < options.Length; i++) { //place them in holder and set variables QuestAnsViewModel t = new QuestAnsViewModel(); t.Text = options[i]; t.Index = i; //If possible answer is in correct answer, checkbox to true if (possibleAnswers.Contains(options[i])) { t.IsTrue = true; } } } AnswerList.ItemsSource = display; var list = new List <Answer>(); list = ansRepo.GetAnswerSelection(); AnswerSelectionList.ItemsSource = list; }