public static TestFlow FillTest(int parTestId) { var res = GetQuest(parTestId); var questions = new List <Question>(); List <Ansver> ansvers; var allQuests = new List <int>(); var d = new DateTime(); int trueAns = 0; int idq = 0; var alLquestions = res.Select(temp => temp.IDQuest).ToList(); byte[] img = new byte[0]; byte[] imgQuestion = new byte[0]; allQuests.AddRange(alLquestions.Distinct()); foreach (var q in allQuests) { ansvers = new List <Ansver>(); foreach (var temp in res) { if (q == temp.IDQuest) { var aa = new Ansver { ID = temp.AnsverID, Text = temp.Ansver }; ansvers.Add(aa); trueAns = temp.TrueAns; d = temp.Constraint; idq = temp.IDQuest; img = temp.Image; imgQuestion = temp.QuestImage; } } String name = (from score in res where score.IDQuest == q select score.Quest).First(); var question = new Question(ansvers, name, trueAns, img, imgQuestion) { ID = idq }; questions.Add(question); } return(new TestFlow(d, questions) { ID = parTestId }); }
/// <summary> /// Удаление варианта ответа /// </summary> private void button_deleteAnsver_Click(object sender, EventArgs e) { if (_radioListBox.SelectedIndex != -1) { // поиск ответа который нужно удалить Ansver deleted = new Ansver(); foreach (var temp in _bindingListQuestions[GetQuestionSelectedIndex()].Ansvers) { if (temp.Text == (string)_radioListBox.SelectedItem) { deleted = temp; } } // Удаление _bindingListQuestions[GetQuestionSelectedIndex()].Ansvers.Remove(deleted); _radioListBox.Items.RemoveAt(_radioListBox.SelectedIndex); } }