Exemplo n.º 1
0
        public async Task <ActionResult <PageRS <AnalysisTestDTO> > > GetTestsAsync([FromBody] SearchPaginatedRQ body)
        {
            var entities = _analysisRepo.GetPaginated(body, out int pageCnt, out int pageNo);

            #region Get_CreatedBy_Users_Details
            var createdByIds     = entities.Select(e => e.CreatedBy);
            var createdByDetails = await _msGraph.GetStudentsByIds(createdByIds);

            #endregion

            #region Get_Student_Users_Details
            var studentIds     = entities.Select(e => e.STS_StudentId);
            var studentDetails = await _msGraph.GetStudentsByIds(studentIds);

            #endregion

            #region Map_Result
            var res = entities.Select(entity =>
            {
                var createdByDetail = createdByDetails.Single(ud => ud.MicrosoftId == entity.CreatedBy);
                var studentDetail   = studentDetails.Single(ud => ud.MicrosoftId == entity.STS_StudentId);
                return(new AnalysisTestDTO(entity, createdByDetail, studentDetail));
            });
            #endregion

            return(new PageRS <AnalysisTestDTO>(res, pageCnt, pageNo));
        }
Exemplo n.º 2
0
        public async Task <ActionResult <IEnumerable <AssignedStudentDTO> > > GetStudentsAssignedToTestAsync([FromRoute] TestType testType, int testId)
        {
            IEnumerable <BaseTestStudentEntity> entities;

            switch (testType)
            {
            case TestType.Synthesis:
                entities = _studentRepo.GetAssignedSynthesis(testId);
                break;

            case TestType.Analysis:
                entities = _studentRepo.GetAssignedAnalysis(testId);
                break;

            default:
                return(StatusCode(500));
            }

            #region Get_Users_Details
            var userIds     = entities.Select(e => e.StudentId);
            var userDetails = await _msGraph.GetStudentsByIds(userIds);

            #endregion

            #region Map_Result
            var res = entities.Select(entity =>
            {
                var userDetail = userDetails.Single(ud => ud.MicrosoftId == entity.StudentId);
                return(new AssignedStudentDTO(entity, userDetail));
            });
            #endregion

            return(Ok(res));
        }
Exemplo n.º 3
0
        public async Task <ActionResult <IEnumerable <SynthesisEvaluationItemDTO> > > SynthesisEvaluationDataAsync([FromRoute] int testId)
        {
            var entities = _synthesisRepo.GetPapers(testId);

            #region Get_Student_Details
            var studentIds     = entities.Select(e => e.StudentId);
            var studentDetails = await _msGraph.GetStudentsByIds(studentIds);

            #endregion

            #region Map_Result
            var res = entities.Select(entity =>
            {
                var studentDetail = studentDetails.Single(ud => ud.MicrosoftId == entity.StudentId);
                return(new SynthesisEvaluationItemDTO(entity, studentDetail));
            });
            #endregion

            return(Ok(res));
        }
Exemplo n.º 4
0
        public async Task <ActionResult <PageRS <TaskDTO> > > GetTasksAsync([FromBody] SearchPaginatedRQ body)
        {
            var entities = _taskRepo.GetPaginated(body, out int pageCnt, out int pageNo);

            #region Get_CreatedBy_Users_Details
            var createdByIds     = entities.Select(e => e.CreatedBy);
            var createdByDetails = await _msGraph.GetStudentsByIds(createdByIds);

            #endregion

            #region Map_Result
            var res = entities.Select(te =>
            {
                var createdByDetail = createdByDetails.Single(ud => ud.MicrosoftId == te.CreatedBy);
                return(new TaskDTO(te, createdByDetail));
            });
            #endregion

            return(new PageRS <TaskDTO>(res, pageCnt, pageNo));
        }