Esempio n. 1
0
        private static bool CanAccessCourse(CourseConfigDto course, string userId, bool isRoot)
        {
            if (isRoot || course.Access == CourseAccess.Public)
            {
                return(true);
            }

            if (course.Access == CourseAccess.Private)
            {
                if (course.Courses.Any(i => CanAccessYear(i, userId, isRoot)))
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 2
0
        public List <CourseConfigDto> ToDto(List <Course> courses)
        {
            // 3) map to dto
            var dtos = new List <CourseConfigDto>();

            foreach (var course in courses)
            {
                var dto = new CourseConfigDto
                {
                    Name      = course.CourseConfig.Name,
                    Desc      = course.CourseConfig.Desc,
                    Disabled  = course.CourseConfig.Disabled,
                    Access    = course.CourseConfig.Access.ParseOrDefault(CourseAccess.Private),
                    Courses   = new List <CourseYearDto>(),
                    Errors    = course.Errors,
                    CourseDir = course.CourseDir,
                };
                course.CourseYears.ForEach(i =>
                {
                    var courseDto = new CourseYearDto(dto)
                    {
                        Year     = i.Year,
                        Teachers = i.SettingsConfig.Teachers,
                    };
                    courseDto.Problems = i.Problems
                                         .Select(j => new ProblemDto(courseDto)
                    {
                        Config = j,
                    }).ToList();

                    dto.Courses.Add(courseDto);
                });
                dtos.Add(dto);
            }

            return(dtos);
        }
Esempio n. 3
0
 public CourseConfigDto CourseConfigDto(CourseConfigDto item = null) => item == null
     ? _courseConfigDto
     : _courseConfigDto = item;
Esempio n. 4
0
 // --------------------------------------
 public CourseYearDto(CourseConfigDto courseConfigDto)
 {
     CourseConfigDto(courseConfigDto);
 }