예제 #1
0
        public async Task <Result <StudentsClassbookResultDto> > GetStudentClassbookAsync(long studentId,
                                                                                          DashboardAnalyticsRequestDto <ClassbookResultType> request, ClaimsPrincipal userContext)
        {
            var error = ValidateGenericRequest(request).Concat(ValidateStudentRights(studentId, userContext));

            if (error.Any())
            {
                return(Result <StudentsClassbookResultDto>
                       .GetError(ErrorCode.ValidationError, string.Join(";\n", error)));
            }

            var result           = new StudentsClassbookResultDto();
            var studentGroupsIds = await _dashboardRepository
                                   .GetGroupsIdsByStudentIdAndPeriodAsync(studentId, request.StartDate, request.FinishDate);

            if (request.IncludeAnalytics.Contains(ClassbookResultType.StudentPresence))
            {
                result.StudentsPresences = await _dashboardRepository
                                           .GetStudentPresenceListByStudentIds(studentId, studentGroupsIds);
            }

            if (request.IncludeAnalytics.Contains(ClassbookResultType.StudentMarks))
            {
                result.StudentsMarks = await _dashboardRepository
                                       .GetStudentMarksListByStudentIds(studentId, studentGroupsIds);
            }

            return(Result <StudentsClassbookResultDto> .GetSuccess(result));
        }
예제 #2
0
        public async Task <Result <StudentsClassbookResultDto> > GetStudentsClassbookAsync(StudentsRequestDto <ClassbookResultType> request)
        {
            var errors = ValidateStudentsRequest(request);

            if (errors.Any())
            {
                return(Result <StudentsClassbookResultDto> .GetError(ErrorCode.ValidationError, string.Join(";\n", errors)));
            }

            var result           = new StudentsClassbookResultDto();
            var studentGroupsIds = request.StudentGroupId.HasValue
                ? new List <long> {
                request.StudentGroupId.Value
            }
                : await _dashboardRepository
            .GetGroupsIdsByCourseIdAsync(request.CourseId.Value, request.StartDate, request.FinishDate);

            var studentsIds = await _dashboardRepository.GetStudentsIdsByGroupIdsAsync(studentGroupsIds);

            if (request.IncludeAnalytics.Contains(ClassbookResultType.StudentPresence))
            {
                result.StudentsPresences = await _dashboardRepository
                                           .GetStudentsPresenceListByStudentIds(studentsIds);
            }

            if (request.IncludeAnalytics.Contains(ClassbookResultType.StudentMarks))
            {
                result.StudentsMarks = await _dashboardRepository
                                       .GetStudentsMarksListByStudentIds(studentsIds);
            }

            return(Result <StudentsClassbookResultDto> .GetSuccess(result));
        }