public void Add(AcademicProgress academicProgress) { SetRelativeEntities(academicProgress); db.Students.Attach(academicProgress.Student); db.Teachers.Attach(academicProgress.Course.Teacher); db.AcademicProgresses.Add(academicProgress); db.SaveChanges(); }
public void Edit(AcademicProgress academicProgress) { var editingProgress = db.AcademicProgresses.Find(academicProgress.id); SetRelativeEntities(editingProgress, academicProgress); editingProgress.date = academicProgress.date; editingProgress.score = academicProgress.score; db.AcademicProgresses.AddOrUpdate(editingProgress); db.SaveChanges(); }
private void SetRelativeEntities(AcademicProgress oldProgress, AcademicProgress newProgress) { var group = db.Students.Find(newProgress.Student.id); oldProgress.Student = group; var teacher = db.Teachers.Find(newProgress.Course.Teacher.id); oldProgress.Course.Teacher = teacher; }
private void SetRelativeEntities(AcademicProgress academicProgress) { var student = db.Students.Find(academicProgress.Student.id); academicProgress.Student = student; var course = db.Courses.Find(academicProgress.Course.id); academicProgress.Course = course; }