Example #1
0
        public void AddCourse(POCO.Course c, ref List<string> errors)
        {
            var db_course = new course();

            try
            {
                db_course.course_level = c.Level;
                db_course.course_description = c.Description;
                db_course.course_title = c.Title;
                this.context.courses.Add(db_course);
                this.context.SaveChanges();
            }
            catch (Exception e)
            {
                errors.Add("Error occured in CourseRepository.AddCourse: " + e);
            }
        }
Example #2
0
        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);
            }
        }
Example #3
0
        public void RemoveCourse(int course_id, ref List<string> errors)
        {
            var db_course = new course();

            try
            {
                db_course = this.context.courses.Find(course_id);
                this.context.courses.Remove(db_course);
                this.context.SaveChanges();
            }
            catch (Exception e)
            {
                errors.Add("Error occured in CourseRepository.RemoveCourse: " + e);
            }
        }
Example #4
0
        public List<Course> GetAllPreReqs(int courseId, ref List<string> errors)
        {
            List<POCO.Course> pocoCourseList = new List<POCO.Course>();
            course db_course = new course();
            IEnumerable<course_preReq> db_preReqCourseList;
            try
            {
                db_preReqCourseList = this.context.course_preReq.Where(x => x.course_id == courseId);

                foreach (course_preReq preReq in db_preReqCourseList)
                {
                    var tempPoco = new POCO.Course();
                    var db_Poco = new course();
                    db_Poco = this.context.courses.Find(preReq.preReq_id);
                    tempPoco.CourseId = db_Poco.course_id;
                    tempPoco.Title = db_Poco.course_title;
                    tempPoco.Description = db_Poco.course_description;
                    tempPoco.Level = db_Poco.course_level;
                    pocoCourseList.Add(tempPoco);
                }
            }
            catch (Exception e)
            {
                errors.Add("Error occured in CourseRepository.GetAllPreReqs: " + e);
            }

            return pocoCourseList;
        }