Ejemplo n.º 1
0
        public bool AddCourse(string CourseName, string CourseDesc, string CourseTeacher, string CourseYear, string CourseDep)
        {
            var myCourse = new Course();
            myCourse.CourseName = CourseName;
            myCourse.CourseDescription = CourseDesc;
             // alu
            myCourse.CourseYear = int.Parse(CourseYear);
            myCourse.CourseDepartement = CourseDep;

            using (CourseContext _db = new CourseContext())
            {
                // Add Courses to DB.
                _db.Courses.Add(myCourse);
                _db.SaveChanges();
            }
            // Success.
            return true;
        }
Ejemplo n.º 2
0
        public bool AddCourse(string CourseName, string CourseDesc, string CourseTeacherFN,string CourseTeacherLN, string CourseYear, string CourseDep)
        {
            var myCourse = new Course();
            myCourse.CourseName = CourseName;
            myCourse.CourseDescription = CourseDesc;
            myCourse.CourseYear = int.Parse(CourseYear);
            myCourse.CourseDepartement = CourseDep;

            using (CourseContext _db = new CourseContext())
            {
                var teacher = (from t in _db.Teachers
                              where t.FirstName.Equals(CourseTeacherFN)&& t.LastName.Equals(CourseTeacherLN)
                              select t).First();
                myCourse.Teachers.Add(teacher);
                teacher.Courses.Add(myCourse);
                // Add Courses to DB.
                _db.Courses.Add(myCourse);
                _db.SaveChanges();
            }
            // Success.
            return true;
        }