public void Add(Schedule schedule) { SetRelativeEntities(schedule); db.Groups.Attach(schedule.Group); db.Courses.Attach(schedule.Course); db.Schedules.Add(schedule); db.SaveChanges(); }
public void Edit(Schedule schedule) { var editingSchedule = db.Schedules.Find(schedule.id); SetRelativeEntities(editingSchedule, schedule); editingSchedule.day = schedule.day; db.Schedules.AddOrUpdate(editingSchedule); db.SaveChanges(); }
private void SetRelativeEntities(Schedule schedule) { var group = db.Groups.Find(schedule.Group.id); schedule.Group = group; var course = db.Courses.Find(schedule.Course.id); schedule.Course = course; }
private void SetRelativeEntities(Schedule oldSchedule, Schedule newSchedule) { var group = db.Groups.Find(newSchedule.Group.id); oldSchedule.Group = group; var course = db.Courses.Find(newSchedule.Course.id); oldSchedule.Course = course; }