Beispiel #1
0
        private static bool CanAccessYear(CourseYearDto courseYear, string userId, bool isRoot)
        {
            var course = courseYear.CourseConfigDto();

            if (isRoot || course.Access == CourseAccess.Public)
            {
                return(true);
            }

            if (courseYear.AllUsers().Contains(userId))
            {
                return(true);
            }

            return(false);
        }
Beispiel #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);
        }
Beispiel #3
0
 public CourseYearDto CourseYearDto(CourseYearDto item = null) => item == null
     ? _courseYearDto
     : _courseYearDto = item;
Beispiel #4
0
 // --------------------------------------
 public ProblemDto(CourseYearDto courseYearDto)
 {
     CourseYearDto(courseYearDto);
 }