Exemple #1
0
        public override CourseResponse SendItem(AbstractMoodleServiceClient client, Disciplina item)
        {
            CreateCourseClient createClient = (CreateCourseClient)client;
            long?categoryId = item.GetMoodleCursoId(ModalidadeAtual, GetCategoryByNameClient, client.GetUnderlyingHttpClient());

            if (!categoryId.HasValue)
            {
                throw new MoodleDataNotExistsException($"O curso [{item.CursoDescricao}]´nõa está adicionado ao MOODLE.");
            }

            CourseRequest request = new CourseRequest()
            {
                CategoryId = categoryId.Value,
                Fullname   = item.DisciplinaNome,
                Shortname  = item.ShortName,
                Visible    = 1
            };

            Task <CourseResponse> task = createClient.Post(request);

            task.Wait();

            CourseResponse response = task.Result;

            LastUrl = createClient.LastUrl;

            return(response);
        }
        private CourseResponse CriarDisciplinaMoodle(Disciplina item, long moodleCategoryId)
        {
            CreateCourseClient client = CreateCourseClient;

            BuildMoodleClient(client, MoodleTokenType.OfficialMoodleApiFunctions);

            CourseRequest request = new CourseRequest()
            {
                CategoryId = moodleCategoryId,
                Fullname   = item.DisciplinaNome,
                Shortname  = item.ShortName,
                Visible    = 1
            };

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

            task.Wait();

            LastUrl = client.LastUrl;
            CourseResponse response = task.Result;

            return(response);
        }