/// <summary>Gets how many Courses exist.<summary>
 public int GetCoursesCount()
 {
     using (DA.SampleObjectContext dataContext = new DA.SampleObjectContext())
     {
         return(dataContext.Courses.Count());
     }
 }
 /// <summary>Gets how many Students exist.<summary>
 public int GetStudentsCount()
 {
     using (DA.SampleObjectContext dataContext = new DA.SampleObjectContext())
     {
         return(dataContext.Students.Count());
     }
 }
 /// <summary>Gets how many Teachers exist.<summary>
 public int GetTeachersCount()
 {
     using (DA.SampleObjectContext dataContext = new DA.SampleObjectContext())
     {
         return(dataContext.Teachers.Count());
     }
 }
        public static void DeleteCourse(int id)
        {
            SampleObjectContext context = new SampleObjectContext();

            DeleteCourse(context, id);

            context.AcceptAllChanges();
            Course.OnCacheNeedsRefresh();
        }
 public static List<Course> FindCourseAPI(SampleObjectContext context, string keyword)
 {
     return (from c in context.Courses
             where
                 c.Name.Contains(keyword)
                 || c.Teacher.FirstName.Contains(keyword)
                 || c.Teacher.LastName.Contains(keyword)
             select c).ToList();
 }
        public static Course CreateCourse(Semester Semester_Parameter, Teacher Teacher_Parameter, string Number_Parameter, string Name_Parameter, CourseStatus Status_Parameter)
        {
            SampleObjectContext context = new SampleObjectContext();
            Course obj = CreateCourse(context, Semester_Parameter, Teacher_Parameter, Number_Parameter, Name_Parameter, Status_Parameter);

            context.AcceptAllChanges();
            Course.OnCacheNeedsRefresh();

            return obj;
        }
        public static Course CreateCourse(SampleObjectContext context, Semester Semester_Parameter, Teacher Teacher_Parameter, string Number_Parameter, string Name_Parameter, CourseStatus Status_Parameter)
        {
            Course obj = new Course();

            obj.Semester = Semester_Parameter;
            obj.Teacher = Teacher_Parameter;
            obj.Number = Number_Parameter;
            obj.Name = Name_Parameter;
            obj.Status = Status_Parameter;

            Validate(context, obj);

            PerformPreCreateLogic(context, obj);

            context.Courses.AddObject(obj);

            PerformPostCreateLogic(context, obj);

            return obj;
        }
 /// <summary>Gets a list of all of the Courses in the database which are associated with the Teacher table via the ID column.</summary>
 /// <param name="teacherID">The ID of the Teacher for which to retrieve the child Courses.</param>
 /// <returns>An IEnumerable of Courses.</returns>
 public static IEnumerable<Course> GetByTeacherID(SampleObjectContext context, int iD)
 {
     var source = context.Courses;
     return (from o in source where o.TeacherID == iD select o);
 }
 public static Course GetBySemesterIDAndNumber(SampleObjectContext context, int semesterID, string number)
 {
     return context.Courses.FirstOrDefault(o => o.SemesterID == semesterID && o.Number == number);
 }
 public static Course GetBySemesterIDAndName(SampleObjectContext context, int semesterID, string name)
 {
     return context.Courses.FirstOrDefault(o => o.SemesterID == semesterID && o.Name == name);
 }
 /// <summary>Returns the Course with the provided primary key value.</summary>
 /// <param name="id">The primary key of the Course to fetch.</param>
 /// <param name="context">The data context to use.</param>
 /// <returns>A single Course, or null if it does not exist.</returns>
 public static Course GetByID(SampleObjectContext context, int ID)
 {
     return context.Courses.SingleOrDefault(o => o.ID == ID);
 }
 /// <summary>Gets how many Students exist.<summary>
 public int GetStudentsCount()
 {
     using(DA.SampleObjectContext dataContext = new DA.SampleObjectContext())
     {
         return dataContext.Students.Count();
     }
 }
 public static Semester GetByName(SampleObjectContext context, string name)
 {
     return context.Semesters.FirstOrDefault(o => o.Name == name);
 }
 public static Semester GetByBeginAndEnd(SampleObjectContext context, DateTime begin, DateTime end)
 {
     return context.Semesters.FirstOrDefault(o => o.Begin == begin && o.End == end);
 }
 /// <summary>Gets a list of all of the Majors in the database.</summary>
 /// <returns>An IEnumerable of Majors.</returns>
 public static IEnumerable<Major> GetAll(SampleObjectContext context)
 {
     return context.Majors;
 }
 /// <summary>Gets a list of all of the Enrollments in the database which are associated with the Student table via the ID column.</summary>
 /// <param name="studentID">The ID of the Student for which to retrieve the child Enrollments.</param>
 /// <returns>An IEnumerable of Enrollments.</returns>
 public static IEnumerable<Enrollment> GetByStudentID(SampleObjectContext context, int iD)
 {
     var source = context.Enrollments;
     return (from o in source where o.StudentID == iD select o);
 }
 /// <summary>Gets a list of all of the Enrollments in the database.</summary>
 /// <returns>An IEnumerable of Enrollments.</returns>
 public static IEnumerable<Enrollment> GetAll(SampleObjectContext context)
 {
     return context.Enrollments;
 }
        /// <summary>When implemented, allows logic to be performed after the object is created using the supplied data context.</summary>
partial         static void PerformPostCreateLogic(SampleObjectContext context, Teacher obj);
partial         static void PerformPreDeleteLogic(SampleObjectContext context, Student obj)
        {
            if (obj.Enrollments != null)
                foreach (DataAccess.Enrollment enrollment in obj.Enrollments)
                    EnrollmentLogic.DeleteEnrollment(context, enrollment.ID);
        }
        /// <summary>When implemented, validates that the object conforms to standard business rules using the supplied data context.</summary>
partial         static void Validate(SampleObjectContext context, Teacher obj);
        /// <summary>When implemented, allows logic to be performed before the object is deleted using the supplied data context.</summary>
partial         static void PerformPreDeleteLogic(SampleObjectContext context, Teacher obj);
 /// <summary>Returns the Enrollment with the provided primary key value.</summary>
 /// <param name="id">The primary key of the Enrollment to fetch.</param>
 /// <param name="context">The data context to use.</param>
 /// <returns>A single Enrollment, or null if it does not exist.</returns>
 public static Enrollment GetByID(SampleObjectContext context, int ID)
 {
     return context.Enrollments.SingleOrDefault(o => o.ID == ID);
 }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            this.DataContext = new SampleObjectContext();
        }
 public static Enrollment GetByStudentIDAndCourseID(SampleObjectContext context, int studentID, int courseID)
 {
     return context.Enrollments.FirstOrDefault(o => o.StudentID == studentID && o.CourseID == courseID);
 }
 /// <summary>Gets a list of all of the Students in the database.</summary>
 /// <returns>An IEnumerable of Students.</returns>
 public static IEnumerable<Student> GetAll(SampleObjectContext context)
 {
     return context.Students;
 }
 /// <summary>Gets a list of all of the Semesters in the database.</summary>
 /// <returns>An IEnumerable of Semesters.</returns>
 public static IEnumerable<Semester> GetAll(SampleObjectContext context)
 {
     return context.Semesters;
 }
 public static Student GetBySSN(SampleObjectContext context, string sSN)
 {
     return context.Students.FirstOrDefault(o => o.SSN == sSN);
 }
 /// <summary>Returns the Semester with the provided primary key value.</summary>
 /// <param name="id">The primary key of the Semester to fetch.</param>
 /// <param name="context">The data context to use.</param>
 /// <returns>A single Semester, or null if it does not exist.</returns>
 public static Semester GetByID(SampleObjectContext context, int ID)
 {
     return context.Semesters.SingleOrDefault(o => o.ID == ID);
 }
 /// <summary>Gets a list of all of the Teachers in the database.</summary>
 /// <returns>An IEnumerable of Teachers.</returns>
 public static IEnumerable<Teacher> GetAll(SampleObjectContext context)
 {
     return context.Teachers;
 }
 /// <summary>Gets how many Courses exist.<summary>
 public int GetCoursesCount()
 {
     using(DA.SampleObjectContext dataContext = new DA.SampleObjectContext())
     {
         return dataContext.Courses.Count();
     }
 }
 public static Teacher GetBySSN(SampleObjectContext context, string sSN)
 {
     return context.Teachers.FirstOrDefault(o => o.SSN == sSN);
 }
 /// <summary>Gets how many Teachers exist.<summary>
 public int GetTeachersCount()
 {
     using(DA.SampleObjectContext dataContext = new DA.SampleObjectContext())
     {
         return dataContext.Teachers.Count();
     }
 }
 /// <summary>Gets a list of all of the Courses in the database.</summary>
 /// <returns>An IEnumerable of Courses.</returns>
 public static IEnumerable<Course> GetAll(SampleObjectContext context)
 {
     return context.Courses;
 }