예제 #1
0
 public void CreateAbsence(List <Absence> absenceList)
 {
     foreach (Absence a in absenceList)
     {
         context.Absences.Add(a);
     }
     context.SaveChanges();
 }
 public void AddEducator(Educator educator)
 {
     if (educator.EducatorId == 0)
     {
         context.Educators.Add(educator);
     }
     else
     {
         Educator dbEntryEducator =
             context.Educators.FirstOrDefault(e => e.EducatorId == educator.EducatorId);
         if (dbEntryEducator != null)
         {
             dbEntryEducator.Name = educator.Name;
         }
     }
     context.SaveChanges();
 }
예제 #3
0
 public void SaveCourse(Course course)
 {
     if (course.CourseId == 0)
     {
         context.Courses.Add(course);
     }
     else
     {
         Course dbEntry = context.Courses.Include(c => c.StudentCourses).FirstOrDefault(c => c.CourseId == course.CourseId);
         if (dbEntry != null)
         {
             dbEntry.Name           = course.Name;
             dbEntry.Educator       = course.Educator;
             dbEntry.Week           = course.Week;
             dbEntry.StartDate      = course.StartDate;
             dbEntry.EndDate        = course.EndDate;
             dbEntry.StudentCourses = course.StudentCourses;
         }
     }
     context.SaveChanges();
 }
예제 #4
0
 public void Create(Education education)
 {
     context.Educations.Add(education);
     context.SaveChanges();
 }
 public void Create(Student student)
 {
     context.Students.Add(student);
     context.SaveChanges();
 }