public void Edit() { if (GroupIndex >= 0 && SubjectIndex >= 0) { var gAndS = GroupsAndSubjects[GroupIndex]; var context = new GroupsAndSubjectsVM(gAndS.InformationAboutSubjects[SubjectIndex], ClassSubjects.ToArray()); var wind = new NewGroupsAndSubjects() { DataContext = context }; wind.GAS.IsEnabled = false; wind.ShowDialog(); if (wind.DialogResult == true) { if ((context.InformationAboutSubjects != null)) { gAndS.InformationAboutSubjects[SubjectIndex] = context.InformationAboutSubjects; if (RequestToDataBase.Instance.requestUpdateGroupsAndSubjects(gAndS, gAndS.InformationAboutSubjects[SubjectIndex])) { RefreshGroupsAndSubjects(); } } } } }
public void Add() { if (GroupIndex >= 0) { var gAndS = GroupsAndSubjects[GroupIndex]; var context = new GroupsAndSubjectsVM(ClassSubjects.ToArray()); var wind = new NewGroupsAndSubjects() { DataContext = context }; wind.ShowDialog(); if (wind.DialogResult == true) { bool exist = false; foreach (var value in gAndS.InformationAboutSubjects) { if (value.Subject.CodeOfSubject == context.InformationAboutSubjects.Subject.CodeOfSubject) { exist = true; MessageBox.Show("Такой предмет уже есть! Добавьте тот предмет которого ещё нету в списке", "Ошибка добавления предмета"); break; } } if ((context.InformationAboutSubjects != null) && (exist == false)) { var items = gAndS.InformationAboutSubjects.Append(context.InformationAboutSubjects).ToArray(); foreach (var item in items) { if (RequestToDataBase.Instance.requestInsertIntoGroupsAndSubjects(gAndS, item)) { RefreshGroupsAndSubjects(); } } } } } }