/// <summary>
 /// Gets the course by identifier.
 /// </summary>
 /// <param name="id">The identifier.</param>
 /// <returns></returns>
 /// <exception cref="System.NotImplementedException"></exception>
 public Course GetCourseById(int id)
 {
     using (var context = new MyApplicationContext())
     {
         return context.Courses.Where(course => course.Id == id).SingleOrDefault();
     }
 }
 /// <summary>
 /// Gets the catalog by identifier.
 /// </summary>
 /// <param name="id">The identifier.</param>
 /// <returns></returns>
 /// <exception cref="System.NotImplementedException"></exception>
 public Catalog GetCatalogById(int id)
 {
     using (var context = new MyApplicationContext())
     {
         return context.Catalogs.Where(catalog => catalog.Id == id).SingleOrDefault();
     }
 }
 /// <summary>
 /// Gets all discountPackages.
 /// </summary>
 /// <returns></returns>
 public IList<DiscountPackage> GetAllDiscountPackages()
 {
     using (var context = new MyApplicationContext())
     {
         return context.DiscountPackages.Select(discountPackage => discountPackage).ToList();
     }
 }
 /// <summary>
 /// Gets all catalogs.
 /// </summary>
 /// <returns></returns>
 public IList<Catalog> GetAllCatalogs()
 {
     using (var context = new MyApplicationContext())
     {
         return context.Catalogs.Select(catalog => catalog).ToList();
     }
 }
 public IList<Catalog> GetAllStudentCatalogsForCourse(Student student, Course course)
 {
     using (var context = new MyApplicationContext())
     {
         return context.Catalogs.Where(catalog => catalog.Student == student && catalog.Exam.Course == course).ToList();
     }
 }
 /// <summary>
 /// Gets the semester by identifier.
 /// </summary>
 /// <param name="id">The identifier.</param>
 /// <returns></returns>
 /// <exception cref="System.NotImplementedException"></exception>
 public Semester GetSemesterById(int id)
 {
     using (var context = new MyApplicationContext())
     {
         return context.Semesters.Where(semester => semester.Id == id).SingleOrDefault();
     }
 }
 /// <summary>
 /// Gets the discountPackage by identifier.
 /// </summary>
 /// <param name="id">The identifier.</param>
 /// <returns></returns>
 /// <exception cref="System.NotImplementedException"></exception>
 public DiscountPackage GetDiscountPackageById(int id)
 {
     using (var context = new MyApplicationContext())
     {
         return context.DiscountPackages.Where(discountPackage => discountPackage.Id == id).SingleOrDefault();
     }
 }
 /// <summary>
 /// Gets all exams.
 /// </summary>
 /// <returns></returns>
 public IList<Exam> GetAllExams()
 {
     using (var context = new MyApplicationContext())
     {
         return context.Exams.Select(exam => exam).ToList();
     }
 }
 /// <summary>
 /// Gets the exam by identifier.
 /// </summary>
 /// <param name="id">The identifier.</param>
 /// <returns></returns>
 /// <exception cref="System.NotImplementedException"></exception>
 public Exam GetExamById(int id)
 {
     using (var context = new MyApplicationContext())
     {
         return context.Exams.Where(exam => exam.Id == id).SingleOrDefault();
     }
 }
 /// <summary>
 /// Gets all semesters.
 /// </summary>
 /// <returns></returns>
 public IList<Semester> GetAllSemesters()
 {
     using (var context = new MyApplicationContext())
     {
         return context.Semesters.Select(semester => semester).ToList();
     }
 }
 /// <summary>
 /// Gets the student by identifier.
 /// </summary>
 /// <param name="id">The identifier.</param>
 /// <returns></returns>
 /// <exception cref="System.NotImplementedException"></exception>
 public Student GetStudentById(int id)
 {
     using (var context = new MyApplicationContext())
     {
         return context.Students.Where(student => student.Id == id).SingleOrDefault();
     }
 }
 /// <summary>
 /// Gets all students.
 /// </summary>
 /// <returns></returns>
 public IList<Student> GetAllStudents()
 {
     using (var context = new MyApplicationContext())
     {
         return context.Students.Select(student => student).ToList();
     }
 }
 /// <summary>
 /// Gets all courses.
 /// </summary>
 /// <returns></returns>
 public IList<Course> GetAllCourses()
 {
     using (var context = new MyApplicationContext())
     {
         return context.Courses.Select(course => course).ToList();
     }
 }
 /// <summary>
 /// Adds the catalog.
 /// </summary>
 /// <param name="catalog">The catalog.</param>
 public void AddCatalog(Catalog catalog)
 {
     using (var context = new MyApplicationContext())
     {
         context.Catalogs.Add(catalog);
         context.SaveChanges();
     }
 }
 /// <summary>
 /// Adds the semester.
 /// </summary>
 /// <param name="semester">The semester.</param>
 public void AddSemester(Semester semester)
 {
     using (var context = new MyApplicationContext())
     {
         context.Semesters.Add(semester);
         context.SaveChanges();
     }
 }
 /// <summary>
 /// Adds the course.
 /// </summary>
 /// <param name="course">The course.</param>
 public void AddCourse(Course course)
 {
     using (var context = new MyApplicationContext())
     {
         context.Courses.Add(course);
         context.SaveChanges();
     }
 }
 /// <summary>
 /// Adds the student.
 /// </summary>
 /// <param name="student">The student.</param>
 public void AddStudent(Student student)
 {
     using (var context = new MyApplicationContext())
     {
         context.Students.Add(student);
         context.SaveChanges();
     }
 }
 /// <summary>
 /// Adds the discountPackage.
 /// </summary>
 /// <param name="discountPackage">The discountPackage.</param>
 public void AddDiscountPackage(DiscountPackage discountPackage)
 {
     using (var context = new MyApplicationContext())
     {
         context.DiscountPackages.Add(discountPackage);
         context.SaveChanges();
     }
 }
 /// <summary>
 /// Adds the exam.
 /// </summary>
 /// <param name="exam">The exam.</param>
 public void AddExam(Exam exam)
 {
     using (var context = new MyApplicationContext())
     {
         context.Exams.Add(exam);
         context.SaveChanges();
     }
 }
 /// <summary>
 /// Deletes the semester.
 /// </summary>
 /// <param name="semester">The semester.</param>
 public void DeleteSemester(Semester semester)
 {
     using (var context = new MyApplicationContext())
     {
         var newProd = new Semester { Id = semester.Id };
         context.Semesters.Attach(newProd);
         context.Semesters.Remove(newProd);
         context.SaveChanges();
     }
 }
 /// <summary>
 /// Deletes the exam.
 /// </summary>
 /// <param name="exam">The exam.</param>
 public void DeleteExam(Exam exam)
 {
     using (var context = new MyApplicationContext())
     {
         var newProd = new Exam { Id = exam.Id };
         context.Exams.Attach(newProd);
         context.Exams.Remove(newProd);
         context.SaveChanges();
     }
 }
 /// <summary>
 /// Deletes the catalog.
 /// </summary>
 /// <param name="catalog">The catalog.</param>
 public void DeleteCatalog(Catalog catalog)
 {
     using (var context = new MyApplicationContext())
     {
         var newProd = new Catalog { Id = catalog.Id };
         context.Catalogs.Attach(newProd);
         context.Catalogs.Remove(newProd);
         context.SaveChanges();
     }
 }
 /// <summary>
 /// Deletes the discountPackage.
 /// </summary>
 /// <param name="discountPackage">The discountPackage.</param>
 public void DeleteDiscountPackage(DiscountPackage discountPackage)
 {
     using (var context = new MyApplicationContext())
     {
         var newProd = new DiscountPackage { Id = discountPackage.Id };
         context.DiscountPackages.Attach(newProd);
         context.DiscountPackages.Remove(newProd);
         context.SaveChanges();
     }
 }
 /// <summary>
 /// Deletes the student.
 /// </summary>
 /// <param name="student">The student.</param>
 public void DeleteStudent(Student student)
 {
     using (var context = new MyApplicationContext())
     {
         var newProd = new Student { Id = student.Id };
         context.Students.Attach(newProd);
         context.Students.Remove(newProd);
         context.SaveChanges();
     }
 }
 /// <summary>
 /// Deletes the course.
 /// </summary>
 /// <param name="course">The course.</param>
 public void DeleteCourse(Course course)
 {
     using (var context = new MyApplicationContext())
     {
         var newProd = new Course { Id = course.Id };
         context.Courses.Attach(newProd);
         context.Courses.Remove(newProd);
         context.SaveChanges();
     }
 }
 /// <summary>
 /// Updates the exam.
 /// </summary>
 /// <param name="exam">The exam.</param>
 /// <exception cref="System.Collections.Generic.KeyNotFoundException"></exception>
 public void UpdateExam(Exam exam)
 {
     using (var context = new MyApplicationContext())
     {
         Exam examRef = context.Exams.Where(c => c.Id == exam.Id).SingleOrDefault();
         if (examRef != null)
         {
             examRef = exam;
             context.SaveChanges();
         }
         else
             throw new KeyNotFoundException();
     }
 }
 /// <summary>
 /// Updates the semester.
 /// </summary>
 /// <param name="semester">The semester.</param>
 /// <exception cref="System.Collections.Generic.KeyNotFoundException"></exception>
 public void UpdateSemester(Semester semester)
 {
     using (var context = new MyApplicationContext())
     {
         Semester semesterRef = context.Semesters.Where(c => c.Id == semester.Id).SingleOrDefault();
         if (semesterRef != null)
         {
             semesterRef = semester;
             context.SaveChanges();
         }
         else
             throw new KeyNotFoundException();
     }
 }
 /// <summary>
 /// Updates the discountPackage.
 /// </summary>
 /// <param name="discountPackage">The discountPackage.</param>
 /// <exception cref="System.Collections.Generic.KeyNotFoundException"></exception>
 public void UpdateDiscountPackage(DiscountPackage discountPackage)
 {
     using (var context = new MyApplicationContext())
     {
         DiscountPackage discountPackageRef = context.DiscountPackages.Where(c => c.Id == discountPackage.Id).SingleOrDefault();
         if (discountPackageRef != null)
         {
             discountPackageRef = discountPackage;
             context.SaveChanges();
         }
         else
             throw new KeyNotFoundException();
     }
 }
 /// <summary>
 /// Updates the catalog.
 /// </summary>
 /// <param name="catalog">The catalog.</param>
 /// <exception cref="System.Collections.Generic.KeyNotFoundException"></exception>
 public void UpdateCatalog(Catalog catalog)
 {
     using (var context = new MyApplicationContext())
     {
         Catalog catalogRef = context.Catalogs.Where(c => c.Id == catalog.Id).SingleOrDefault();
         if (catalogRef != null)
         {
             catalogRef = catalog;
             context.SaveChanges();
         }
         else
             throw new KeyNotFoundException();
     }
 }
 /// <summary>
 /// Updates the course.
 /// </summary>
 /// <param name="course">The course.</param>
 /// <exception cref="System.Collections.Generic.KeyNotFoundException"></exception>
 public void UpdateCourse(Course course)
 {
     using (var context = new MyApplicationContext())
     {
         Course courseRef = context.Courses.Where(c => c.Id == course.Id).SingleOrDefault();
         if (courseRef != null)
         {
             courseRef = course;
             context.SaveChanges();
         }
         else
             throw new KeyNotFoundException();
     }
 }