void GetCurrentStudents(University_Group obj) { if (obj!=null) { using (_ujc = new UniversityEntities()) { var _studs = _ujc.University_Group.Where(gr => gr.Group_ID == obj.Group_ID).FirstOrDefault(); Students = new ObservableCollection<University_Student>(_studs.University_Student.ToList()); } } }
void GetCurrentSubjects(University_Group obj) { if (obj != null) { using (_ujc = new UniversityEntities()) { var _teach = _ujc.University_Group.Where(s => s.Group_ID == obj.Group_ID).FirstOrDefault(); CurrentSubjects = new ObservableCollection<University_Subject>(_teach.University_Subject.ToList()); } } }
private void EditGroupFromDB(University_Group obj) { try { using (_ujc = new UniversityEntities()) { var _group = _ujc.University_Group.Where(s => s.Group_ID == obj.Group_ID).FirstOrDefault(); _group.Group_Name = GroupNameEdit; _ujc.SaveChanges(); } } catch { } finally { RefreshIt(); } }
private void AddNewGroupToDB(string obj) { try { using (_ujc = new UniversityEntities()) { University_Group _group = new University_Group(); _group.Group_Name = obj; _ujc.University_Group.Add(_group); _ujc.SaveChanges(); } } catch { } finally { RefreshIt(); } }
//Command Methods private void DeleteGroupFromDB(University_Group obj) { try { using (_ujc = new UniversityEntities()) { var _group = _ujc.University_Group.Where(s => s.Group_ID == obj.Group_ID).FirstOrDefault(); _ujc.University_Group.Remove(_group); _ujc.SaveChanges(); } } finally { RefreshIt(); } }