public async Task <IList <StudentViewModel> > GetAllStudentsAsync(string accessToken)
        {
            var allStudentsTask    = _apiUtil.GetAsync <IList <StudentViewModel> >($"{_config.Value.Urls.Api.Https}/api/students", accessToken);
            var activeStudentsTask = _apiUtil.GetAsync <IList <StudentViewModel> >($"{_config.Value.Urls.Api.Https}/api/students/active", accessToken);

            var allStudents    = await allStudentsTask;
            var activeStudents = await activeStudentsTask;

            foreach (var student in allStudents)
            {
                student.IsActive = activeStudents.Any(x => x.Id == student.Id);
            }

            return(allStudents);
        }
        public async Task <IList <MentorViewModel> > GetAllMentorsAsync(string accessToken)
        {
            var allMentors = await
                             _apiUtil.GetAsync <IList <MentorViewModel> >($"{_config.Value.Urls.Api.Https}/api/mentors", accessToken);

            var activeMentors = await
                                _apiUtil.GetAsync <IList <MentorViewModel> >($"{_config.Value.Urls.Api.Https}/api/mentors/active", accessToken);

            foreach (var mentor in allMentors)
            {
                mentor.IsActive = activeMentors.Any(x => x.Id == mentor.Id);
            }

            return(allMentors);
        }
        public async Task <IList <StudentGroupViewModel> > GetAllStudentGroupsAsync(string accessToken)
        {
            var studentGroupsTask = _apiUtil.GetAsync <IList <StudentGroupDto> >($"{_config.Value.Urls.Api.Https}/api/student_groups", accessToken);
            var studentsTask      = _studentService.GetAllStudentsAsync(accessToken);
            var mentorsTask       = _mentorService.GetAllMentorsAsync(accessToken);
            var coursesTask       = _courseService.GetAllCoursesAsync(accessToken);

            var studentGroups = _mapper.Map <IList <StudentGroupViewModel> >(await studentGroupsTask);
            var students      = await studentsTask;
            var mentors       = await mentorsTask;
            var courses       = await coursesTask;

            foreach (var item in studentGroups)
            {
                item.Students = item.Students.Select(student =>
                {
                    var foundStudent = students.FirstOrDefault(x => x.Id == student.Id);

                    if (foundStudent != null)
                    {
                        return(_mapper.Map <StudentViewModel>(foundStudent));
                    }
                    else
                    {
                        return(student);
                    }
                }).ToList();

                item.Mentors = item.Mentors.Select(mentor =>
                {
                    var foundMentor = mentors.FirstOrDefault(x => x.Id == mentor.Id);

                    if (foundMentor != null)
                    {
                        return(_mapper.Map <MentorViewModel>(foundMentor));
                    }
                    else
                    {
                        return(mentor);
                    }
                }).ToList();

                item.Course.Name = courses.Where(x => x.Id == item.Course.Id).FirstOrDefault()?.Name;
            }

            return(studentGroups);
        }
        public async Task <ActionResult <IList <AccountDto> > > GetAllAccounts()
        {
            var accounts = await _apiUtil.GetAsync <IList <AccountDto> >($"{_config.Value.Urls.Api.Https}/api/accounts", _protector.Unprotect(Request.Cookies["accessToken"]));

            return(Ok(accounts));
        }
Beispiel #5
0
        public async Task <IList <StudentViewModel> > GetAllStudents(string accessToken)
        {
            var students = await _apiUtil.GetAsync <IList <StudentViewModel> >($"{_config.Value.Urls.Api.Https}/api/students", accessToken);

            return(students);
        }
        public async Task <ActionResult <IList <AccountDto> > > GetAllAccounts()
        {
            var accounts = await _apiUtil.GetAsync <IList <AccountDto> >($"{_config.Value.Urls.Api.Https}/api/accounts", HttpContext.Session.GetString("accessToken"));

            return(Ok(accounts));
        }
Beispiel #7
0
 public async Task <IList <ThemeViewModel> > GetAllThemesAsync(string accessToken)
 {
     return(await
            _apiUtil.GetAsync <IList <ThemeViewModel> >($"{_config.Value.Urls.Api.Https}/api/themes", accessToken));
 }
Beispiel #8
0
        public async Task <IList <MentorViewModel> > GetAllMentorsAsync(string accessToken)
        {
            var courses = await _apiUtil.GetAsync <IList <MentorViewModel> >($"{_config.Value.Urls.Api.Https}/api/mentors", accessToken);

            return(courses);
        }
        public async Task <IList <CourseViewModel> > GetAllCoursesAsync(string accessToken)
        {
            var courses = _mapper.Map <IList <CourseViewModel> >(await _apiUtil.GetAsync <IList <CourseDto> >($"{_config.Value.Urls.Api.Https}/api/courses", accessToken));

            return(courses);
        }