public void AddTeacher(TeacherModel teacher) { string teacherID; _dal.AddTeacher(teacher, out teacherID); teacher.TeacherID = teacherID; Teachers.Add(teacher); TeacherChangedEvent?.Invoke(OperationType.Add, teacher); }
public void ChangeClass(string className) { if (!string.IsNullOrEmpty(className)) { //update current class ID CurrentClassID = (ClassType)CurrentClassType == ClassType.Regular ? _regular.RegularClassCollection.Where(c => c.ClassName == className).First().ClassID : _block.BlockClassCollection.Where(c => c.ClassName == className).First().ClassID; //update default teacher ID CurrentTeacherID = (ClassType)CurrentClassType == ClassType.Regular ? _regular.RegularClassCollection.Where(c => c.ClassName == className).First().TeacherID : _block.BlockClassCollection.Where(c => c.ClassName == className).First().TeacherID; //update teacher name in UI TeacherChangedEvent?.Invoke(TeacherManagementBussiness.Instance.Teachers.Where(t => t.TeacherID == CurrentTeacherID).First().TeacherName); //update trainees if ((ClassType)CurrentClassType == ClassType.Regular) { _regularTrainees.GetTrainees(CurrentClassID); } else { if (_isUsedForPayment) { _blockTrainees.GetTraineesNotPay(CurrentClassID); } else { _blockTrainees.GetTrainees(CurrentClassID); } } SelectedClassChangedEvent?.Invoke((ClassType)CurrentClassType == ClassType.Regular ? (ClassModel)_regular.RegularClassCollection.Where(c => c.ClassName == className).First() : (ClassModel)_block.BlockClassCollection.Where(c => c.ClassName == className).First()); } }
public void UpdateTeacher(TeacherModel teacher) { _dal.UpdateTeacher(teacher); TeacherChangedEvent?.Invoke(OperationType.Update, teacher, Teachers.Where(t => t.TeacherID == teacher.TeacherID).First()); Teachers[Teachers.IndexOf(Teachers.Where(t => t.TeacherID == teacher.TeacherID).First())] = teacher; }