Пример #1
0
        public async Task <IActionResult> GetStatusTaskAsync([FromServices] ICourseBusiness courseBusiness)
        {
            var coordId = Guid.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);

            if (!(await courseBusiness.FindByCoordIdTaskAsync(coordId) is CourseVO course))
            {
                return(NotFound("Você não possui um curso cadastrado!"));
            }

            int lessonCount = await _lessonBusiness.FindCountByCourseIdTaskAsync(course.CourseId);

            int disciplinesCount = await _disciplineBusiness.FindCountByCourseIdTaskAsync(course.CourseId);

            int classesCount = await _classBusiness.FindCountByCourseIdTaskAsync(course.CourseId);

            int studentCount = await _studentBusiness.FindCountByCourseIdTaskAsync(course.CourseId);

            List <LessonDisciplineVO> fiveLastLessons = await _lessonBusiness.FindFiveLastLessonsByCourseIdTaskAsync(course.CourseId);

            return(Ok(new StatusVO
            {
                ClassesCouunt = classesCount,
                DisciplinesCount = disciplinesCount,
                LessonsCount = lessonCount,
                StudentsCount = studentCount,
                FiveLastLessons = fiveLastLessons
            }));
        }