public void SaveData() { List <Answer> saveList = new List <Answer>(); List <Answer> updateList = new List <Answer>(); List <Answer> deleteList = new List <Answer>(); //Разделение вопросов на группы AnsverControls.ForEach(o => { var z = o as EditAnsverContol; if (z.IsChanged) { bool isUpdate = false; Ansvers.ForEach(p => { if (z.Ansver.Equals(p)) { updateList.Add(z.Ansver); isUpdate = true; } }); if (!isUpdate) { saveList.Add(z.Ansver); } } }); deleteList = GetDeleteList(); //Сохранение, обновление, удаление Save(saveList); Update(updateList); Delete(deleteList); }
private List <Control> CreateControls() { List <Control> ansverControls = new List <Control>(); Ansvers.ForEach(x => ansverControls.Add(GetControl(x))); ansverControls.ForEach(x => Controls.Add(x)); return(ansverControls); }