public VMGroups() { entities = DB.GetDB(); LoadGroups(); Groups = new ObservableCollection <Group>(entities.Groups); Specials = new ObservableCollection <Special>(entities.Specials); AddGroup = new CustomCommand(() => { var group = new Group { Number = "Номер группы" }; entities.Groups.Add(group); SelectedGroup = group; }); SaveGroups = new CustomCommand(() => { try { entities.SaveChanges(); LoadGroups(); } catch (Exception ex) { System.Windows.MessageBox.Show(ex.Message); } }); OpenSpecials = new CustomCommand(() => { CurrentPage = new WinSpecials(); SignalChanged("CurrentPage"); }); OpenGroups = new CustomCommand(() => { CurrentPage = new WinGroups(); SignalChanged("CurrentPage"); }); }
public static Entities2 GetDB() { if (Entities2 == null) { Entities2 = new Entities2(); } return(Entities2); }
public MainVM() { entities = DB.GetDB(); Specials = new ObservableCollection <Special>(entities.Specials); OpenSpecials = new CustomCommand(() => { CurrentPage = new WinSpecials(); SignalChanged("CurrentPage"); }); OpenGroups = new CustomCommand(() => { CurrentPage = new WinGroups(); SignalChanged("CurrentPage"); }); OpenStudents = new CustomCommand(() => { CurrentPage = new WinSudents(); SignalChanged("CurrentPage"); }); OpenList = new CustomCommand(() => { CurrentPage = new MainPage(); SignalChanged("CurrentPage"); }); }