public bool UpdateTeacher(string _teacherID, Teacher _newTeacher) { bool success = true; int index = 0; List <Teacher> teachers = GetAllTeachers(); for (; index < teachers.Count; index++) { if (_teacherID == teachers[index].ID) { break; } } if (teachers[index].SurName != _newTeacher.SurName) { success = teacherDA.UpdateTeacher(_teacherID, Teacher.Column[1], _newTeacher.SurName); } if (teachers[index].FirstName != _newTeacher.FirstName) { success = teacherDA.UpdateTeacher(_teacherID, Teacher.Column[2], _newTeacher.FirstName); } if (!ImageHelper.SameImage(teachers[index].Avatar, _newTeacher.Avatar)) { success = teacherDA.UpdateTeacher(_teacherID, Teacher.Column[3], _newTeacher.GetAvatar()); } if (teachers[index].DateBorn.Date != _newTeacher.DateBorn.Date) { success = teacherDA.UpdateTeacher(_teacherID, Teacher.Column[4], _newTeacher.DateBorn.Date); } if (teachers[index].Sex != _newTeacher.Sex) { success = teacherDA.UpdateTeacher(_teacherID, Teacher.Column[5], Convert.ToInt32(_newTeacher.Sex)); } if (teachers[index].Address != _newTeacher.Address) { success = teacherDA.UpdateTeacher(_teacherID, Teacher.Column[6], _newTeacher.Address); } if (teachers[index].Phone != _newTeacher.Phone) { success = teacherDA.UpdateTeacher(_teacherID, Teacher.Column[7], _newTeacher.Phone); } if (teachers[index].Mail != _newTeacher.Mail) { success = teacherDA.UpdateTeacher(_teacherID, Teacher.Column[8], _newTeacher.Mail); } if (teachers[index].Subject.Name != _newTeacher.Subject.Name) { success = teacherDA.UpdateTeacher(_teacherID, Teacher.Column[9], _newTeacher.Subject.ID); } if (_newTeacher.Type != teachers[index].Type) { switch (_newTeacher.Type) { case Teacher.TeacherType.Teacher: success = teacherDA.UpdateTeacher(_teacherID, Teacher.Column[10], "0"); success = teacherDA.UpdateTeacher(_teacherID, Teacher.Column[11], "0"); break; case Teacher.TeacherType.Adminstrator: success = teacherDA.UpdateTeacher(_teacherID, Teacher.Column[10], "0"); success = teacherDA.UpdateTeacher(_teacherID, Teacher.Column[11], "1"); break; case Teacher.TeacherType.Ministry: success = teacherDA.UpdateTeacher(_teacherID, Teacher.Column[10], "1"); success = teacherDA.UpdateTeacher(_teacherID, Teacher.Column[11], "0"); break; case Teacher.TeacherType.FormerTeacher: break; default: break; } } if (teachers[index].Position != _newTeacher.Position) { success = teacherDA.UpdateTeacher(_teacherID, Teacher.Column[12], _newTeacher.Position); } teachers[index] = _newTeacher; return(success); }