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); }
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); }
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)); }
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); } }
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()); }
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); } }
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); } }
public async Task <bool> UpdateCourseAsync(CourseDto item) { return(await _courseRepo.UpdateAsync(CourseConverter.Convert(item))); }
public async Task <CourseDto> CreateCourseAsync(CourseDto item) { return(CourseConverter.Convert(await _courseRepo.CreateAsync(CourseConverter.Convert(item)))); }
public async Task <List <CourseDto> > GetCourseByDirectionIdAsync(Guid id) { return(CourseConverter.Convert(await _courseRepo.GetByDirectionIdAsync(id))); }
public async Task <List <CourseDto> > GetAllCourseAsync() { return(CourseConverter.Convert(await _courseRepo.GetAllAsync())); }