public void AssignPreReqToCourse(int courseId, int preReqCourseId, ref List<string> errors) { course db_coursePreReq = new course(); course_preReq db_preReq = new course_preReq(); try { db_coursePreReq = this.context.courses.Find(preReqCourseId); db_preReq.course_id = courseId; db_preReq.preReq_id = preReqCourseId; db_preReq.preReq_title = db_coursePreReq.course_title; this.context.course_preReq.Add(db_preReq); this.context.SaveChanges(); } catch (Exception e) { errors.Add("Error occured in CourseRepository.AssignPreReqToCourse: " + e); } }
public void RemovePreReqFromCourse(int courseId, int preReqToRemoveCourseId, ref List<string> errors) { course_preReq db_preReq = new course_preReq(); try { db_preReq = this.context.course_preReq.Where(x => x.course_id == courseId && x.preReq_id == preReqToRemoveCourseId).First(); this.context.course_preReq.Remove(db_preReq); this.context.SaveChanges(); } catch (Exception e) { errors.Add("Error occured in in CourseRepository.RemovePreReqFromCourse: " + e); } }