Exemplo n.º 1
0
        public void Add(Course course)
        {
            SetRelativeEntities(course);
            db.Teachers.Attach(course.Teacher);

            db.Courses.Add(course);

            db.SaveChanges();
        }
Exemplo n.º 2
0
        public void Edit(Course course)
        {
            var editingCourse = db.Courses.Find(course.id);

            SetRelativeEntities(editingCourse, course);
            editingCourse.name = course.name;

            db.Courses.AddOrUpdate(editingCourse);
            db.SaveChanges();
        }
Exemplo n.º 3
0
 private void SetRelativeEntities(Course course)
 {
     var teacher = db.Teachers.Find(course.Teacher.id);
     course.Teacher = teacher;
 }
Exemplo n.º 4
0
 private void SetRelativeEntities(Course oldCourse, Course newCourse)
 {
     var teacher = db.Teachers.Find(newCourse.Teacher.id);
     oldCourse.Teacher = teacher;
 }