public Educator Delete(long educatorId)
        {
            Educator educator = context.Educators.Find(educatorId);

            if (educator != null)
            {
                context.Educators.Remove((educator));
                context.SaveChanges();
            }

            return(educator);
        }
        public void EditEducator(Educator educator)
        {
            Educator dbEntryEducator =
                context.Educators.FirstOrDefault(e => e.EducatorId == educator.EducatorId);

            if (dbEntryEducator != null)
            {
                dbEntryEducator.Name = educator.Name;
            }

            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();
 }
Ejemplo n.º 4
0
        public List <Education> EducationsByEducator(Educator educator)
        {
            List <Education> educations = new List <Education>();

            List <StudentCourse> studentCourses = context.StudentCourses.Include(sc => sc.Course.Week).Where(sc => sc.Course.Educator.EducatorId == educator.EducatorId).ToList();

            foreach (StudentCourse studentCourse in studentCourses)
            {
                IQueryable students = context.Students.Where(s => s.StudentId == studentCourse.StudentId);
                foreach (Student student in students)
                {
                    educations.Add(context.Educations.FirstOrDefault(e => e.EducationId == student.EducationId));
                }
            }

            educations = educations.Distinct().ToList();

            return(educations);
        }
Ejemplo n.º 5
0
 public List <Course> CoursesByEducator(Educator educator)
 {
     return(context.Courses.Include(c => c.Week).Where(c => c.Educator.EducatorId == educator.EducatorId).ToList());
 }