예제 #1
0
 public CourseBO Create(CourseBO course)
 {
     using (var uow = _facade.UnitOfWork)
     {
         var fullyConvertedCourse = ConvertCourseWithSectionsAndLessons(course);
         var courseCreated        = uow.CourseRepo.Create(fullyConvertedCourse);
         uow.Complete();
         return(_crsConv.Convert(courseCreated));
     }
 }
        public async Task <DirectionDto> GetDirectionByIdAsync(Guid id)
        {
            DirectionDto direction = DirectionConverter.Convert(await _directionRepo.GetByIdAsync(id));

            direction.Administration = AdministrationConverter.Convert(await _adminRepo.GetByDirectionIdAsync(id));
            direction.Courses        = CourseConverter.Convert(await _courseRepo.GetByDirectionIdAsync(id));
            return(direction);
        }
예제 #3
0
        public async Task <CourseDto> GetCourseByIdAsync(Guid id)
        {
            CourseDto course = CourseConverter.Convert(await _courseRepo.GetByIdAsync(id));

            course.DirectionName = _directionRepo.GetByIdAsync(course.DirectionId).Result.Name;
            course.Groups        = GroupConverter.Convert(await _groupRepo.GetByCourseIdAsync(id));
            course.Pages         = PageConverter.Convert(await _pageRepo.GetByCourseIdAsync(id));
            return(course);
        }
예제 #4
0
        public async Task <IHttpActionResult> GetCourse(Guid id)
        {
            if (!(await Db.Activities.FindAsync(id) is Course course))
            {
                return(NotFound());
            }

            var converter = new CourseConverter(Db);
            var dto       = converter.Convert(id);

            return(Ok(dto));
        }
예제 #5
0
        public CategoryBO Get(int id)
        {
            using (var uow = _facade.UnitOfWork)
            {
                var catFromDb = uow.CategoryRepo.Get(id);
                if (catFromDb == null)
                {
                    return(null);
                }
                var convCourses = catFromDb.Courses?.Select(c => _crsConv.Convert(c)).ToList();

                var category = _categoryConv.Convert(catFromDb);
                category.Courses = convCourses;

                uow.Complete();
                return(category);
            }
        }
예제 #6
0
        public IQueryable <CourseDto> GetCourses(string organiser, string curriculum, string semester)
        {
            var list = new List <CourseDto>();

            var org = Db.Organisers.SingleOrDefault(x => x.ShortName.Equals(organiser));

            if (org == null)
            {
                return(list.AsQueryable());
            }

            var curr = org.Curricula.FirstOrDefault(x => x.ShortName.Equals(curriculum));

            if (curr == null)
            {
                return(list.AsQueryable());
            }

            var sem = Db.Semesters.SingleOrDefault(x => x.Name.Equals(semester));

            if (sem == null)
            {
                return(list.AsQueryable());
            }

            var allCourses = Db.Activities.OfType <Course>().Where(x =>
                                                                   x.SemesterGroups.Any(g =>
                                                                                        g.CapacityGroup.CurriculumGroup.Curriculum.Id == curr.Id &&
                                                                                        g.IsAvailable &&
                                                                                        g.Semester.Id == sem.Id)).ToList();

            var converter = new CourseConverter(Db);

            foreach (var course in allCourses)
            {
                list.Add(converter.Convert(course));
            }

            return(list.AsQueryable());
        }
예제 #7
0
        public SectionBO Get(int id)
        {
            using (var uow = _facade.UnitOfWork)
            {
                SectionBO section   = null;
                var       secFromDb = uow.SectionRepo.Get(id);
                if (secFromDb != null)
                {
                    var convCourse  = _crsConv.Convert(secFromDb.Course);
                    var convLessons = secFromDb.Lessons?.Select(l => _lesConv.Convert(l)).ToList();
                    section         = _sectionConv.Convert(secFromDb);
                    section.Course  = convCourse;
                    section.Lessons = convLessons;

                    /*section.Lessons = uow.LessonRepo.GetAllById(section.LessonIds)
                     * .Select(l => _lesConv.Convert(l))
                     * .ToList();*/
                }
                uow.Complete();

                return(section);
            }
        }
예제 #8
0
 public UserBO Get(int id)
 {
     using (var uow = _facade.UnitOfWork)
     {
         var user = _userConv.Convert(uow.UserRepo.Get(id));
         if (user != null)
         {
             if (user.CourseIds != null)
             {
                 user.Courses = uow.CourseRepo.GetAllById(user.CourseIds).Select(c => _crsConv.Convert(c)).ToList();
             }
         }
         return(user);
     }
 }
예제 #9
0
 public async Task <bool> UpdateCourseAsync(CourseDto item)
 {
     return(await _courseRepo.UpdateAsync(CourseConverter.Convert(item)));
 }
예제 #10
0
 public async Task <CourseDto> CreateCourseAsync(CourseDto item)
 {
     return(CourseConverter.Convert(await _courseRepo.CreateAsync(CourseConverter.Convert(item))));
 }
예제 #11
0
 public async Task <List <CourseDto> > GetCourseByDirectionIdAsync(Guid id)
 {
     return(CourseConverter.Convert(await _courseRepo.GetByDirectionIdAsync(id)));
 }
예제 #12
0
 public async Task <List <CourseDto> > GetAllCourseAsync()
 {
     return(CourseConverter.Convert(await _courseRepo.GetAllAsync()));
 }