Esempio n. 1
0
        public async Task <IActionResult> GetTranscriptRequestProgressForStudent(int id)
        {
            var studentTranscript = await _transcriptRepository.GetStudentTranscriptByPortfolioIdAsync(id);

            var result = new StudentRequestProgressResponseModel
            {
                Student  = await _transcriptService.GetStudentTranscriptResponseModelAsync(studentTranscript, id),
                Progress = await _transcriptRequestService.GetTranscriptRequestsTimelineByPortfolioIdAsync(portfolioId : id, userAccountId : studentTranscript.UserAccountId, translationLanguageId : 2, includeRequested : false)
            };

            return(Ok(result));
        }
Esempio n. 2
0
        public async Task <IActionResult> GetStudentTranscriptForCurrentSchool(string query = "", string filterByProperty = "", string filterByValue = "", string orderBy = "", SortOrder sortOrder = SortOrder.ASC, int skip = 0, int take = int.MaxValue)
        {
            // @TODO: Check if the current user is an educator and has permission to view Transcripts => THERE IS ALREADY A CHECK IN FE, THIS IS NECESSARY ONLY TO PROTECT THE API FROM PEOPLE USING SOFTWARE LIKE POSTMAN
            // @TODO: The max number of records per school is 1k so It seems reasonable to assume the 1k records will fit in memory
            // and do all the manipulation (query, filter, sorting, skip, take) with LINQ (this will be cheaper and faster) instead of SQL.
            // Cache the list in Redis and make sure we update the cache when a new transcript is imported or deleted
            var educatorId    = GetClaim <int>(CcClaimType.EducatorId);
            var currentSchool = await _institutionRepository.GetDefaultInstitutionByEducatorIdAsync(educatorId);

            var studentTranscriptCompleteList = await _transcriptRepository.GetStudentTranscriptBySchoolIdAsync(currentSchool.Id);

            var studentTranscriptSearchPredicate = _transcriptService.GetStudentTranscriptSearchPredicate(query);
            var studentTranscriptLinqedList      = _linqWrapperService.GetLinqedList(studentTranscriptCompleteList, studentTranscriptSearchPredicate, filterByProperty, filterByValue, orderBy, sortOrder, skip, take);

            var result = new ItemsCountModel <StudentTranscriptResponseModel>
            {
                Items = await _transcriptService.GetStudentTranscriptResponseModelAsync(studentTranscriptLinqedList.Items),
                Count = studentTranscriptLinqedList.Count
            };

            return(Ok(result));
        }