public override ParallelSendResult <AlunoDisciplinaViewModel, GetEnrolmentsByUserIdResponse> SendAll()
        {
            Result = new ParallelSendResult <AlunoDisciplinaViewModel, GetEnrolmentsByUserIdResponse>();

            IEnumerable <AlunoDisciplinaViewModel> data = GetData("");

            if (data == null)
            {
                return(Result);
            }

            var factory = new HttpClientFactory();

            HttpClient                    = factory.CreateMoodleHttpClient();
            CreateCourseClient            = new CreateCourseClient();
            CreateCategoryClient          = new CreateCategoryClient();
            CreateUserClient              = new CreateUserClient();
            GetCategoryByNameClient       = new GetCategoryByNameClient();
            GetCourseByNameClient         = new GetCourseByNameClient();
            GetUserByUsernameClient       = new GetUserByUsernameClient();
            EnrolmentClient               = new EnrolmentClient();
            GetEnrolementsrByUserIdClient = new GetEnrolementsrByUserIdClient();

            CreateCourseClient.AddHttpClient(HttpClient);
            CreateCategoryClient.AddHttpClient(HttpClient);
            CreateUserClient.AddHttpClient(HttpClient);
            GetCategoryByNameClient.AddHttpClient(HttpClient);
            GetCourseByNameClient.AddHttpClient(HttpClient);
            GetUserByUsernameClient.AddHttpClient(HttpClient);
            EnrolmentClient.AddHttpClient(HttpClient);
            GetEnrolementsrByUserIdClient.AddHttpClient(HttpClient);

            foreach (var modalidade in Modalidades)
            {
                ModalidadeAtual = modalidade;

                this.AddMoodleBaseUrl(modalidade.MoodleUrl)
                .AddMoodleToken(modalidade.MoodleToken)
                .AddMoodleGetInfoServiceToken(modalidade.MoodleGetInfoServiceToken)
                .AddMoodleServiceUrl(modalidade.MoodleServiceUrl);

                this.AddMoodleCategoryParent(modalidade.MoodleCategoryParent)
                .AddMoodleDescriptionFormat(modalidade.MoodleDescriptionFormat);

                var alunos = data.Where(x => x.Aluno.IdModalidade == modalidade.IdModalidade).ToArray();

                if (UseParallelism)
                {
                    ProcessWithParallelism(alunos, null, null);
                }
                else
                {
                    ProcessWithRegularForeach(alunos, null, null);
                }
            }

            return(Result);
        }
        private GetEnrolmentsByUserIdResponse GetUserEnrolment(InternalMoodleData moodleData)
        {
            GetEnrolementsrByUserIdClient client = GetEnrolementsrByUserIdClient;

            BuildMoodleClient(client, MoodleTokenType.LocalMoodleExternalApiGetInfoToken);

            GetEnrolmentsByUserIdRequest request = new GetEnrolmentsByUserIdRequest()
            {
                UserId     = moodleData.MoodleUserId,
                CategoryId = moodleData.MoodleCategoryId,
                CourseId   = moodleData.MoodleCourseId,
                RoleId     = Constantes.ROLEID_ALUNO
            };

            Task <GetEnrolmentsByUserIdResponse> task = client.Post(request);

            task.Wait();

            GetEnrolmentsByUserIdResponse response = task.Result;

            return(response);
        }