Beispiel #1
0
 internal static CourseViewModel FromEntity(CourseIndex index)
 {
     return(new CourseViewModel
     {
         SubjectId = index.Course.Subject.Id,
         Image = index.Course.Image,
         Order = index.Course.Order,
         Name = index.Course.Name,
         Id = index.Course.Id,
         TeacherInChargeId = index.Course.TeacherInCharge.Id,
         TeacherInChargeName = index.Course.TeacherInCharge.Name,
         Classes = ClassViewModel.FromEntityList(index.ClassesInfo)
     });
 }
 internal static Class ToEntity(ClassViewModel klass, Course course, Teacher teacher)
 {
     return(new Class
     {
         Id = klass.Id,
         CreatedAt = klass.CreatedAt,
         Active = klass.Active,
         DeliveryDays = klass.DeliveryDays,
         Content = klass.Content,
         Name = klass.Name,
         Order = klass.Order,
         ContentType = klass.ContentType,
         Teacher = teacher,
         Course = course
     });
 }
Beispiel #3
0
 public static CourseViewModel FromEntity(Course item, int depth)
 {
     return(new CourseViewModel
     {
         Active = item.Active,
         CreatedAt = item.CreatedAt,
         SubjectId = item.Subject.Id,
         SubjectName = item.Subject.Name,
         KnowledgeAreaName = item.Subject.KnowledgeArea.Name,
         Image = item.Image,
         Order = item.Order,
         Name = item.Name,
         Id = item.Id,
         TeacherInChargeId = item.TeacherInCharge.Id,
         TeacherInChargeName = item.TeacherInCharge.Name,
         Classes = depth > 2
             ? ClassViewModel.FromEntityList(item.Classes.Where(a => a.Active).OrderBy(x => x.Order), depth)
             : new List <ClassViewModel>()
     });
 }