/// <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 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>
 /// 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 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 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>
 /// 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 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 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>
 /// 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 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 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>
 /// 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 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 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();
     }
 }
 /// <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 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 student.
 /// </summary>
 /// <param name="student">The student.</param>
 /// <exception cref="System.Collections.Generic.KeyNotFoundException"></exception>
 public void UpdateStudent(Student student)
 {
     using (var context = new MyApplicationContext())
     {
         Student studentRef = context.Students.Where(c => c.Id == student.Id).SingleOrDefault();
         if (studentRef != null)
         {
             studentRef = student;
             context.SaveChanges();
         }
         else
             throw new KeyNotFoundException();
     }
 }