示例#1
0
        private async Task RemoveStepsFromLesson(StepikApiLesson lesson, List <int> removeStepsIds, CourseExportResults results)
        {
            var realStepsIds = lesson.StepsIds;

            var newPosition = 0;

            foreach (var stepId in realStepsIds)
            {
                if (removeStepsIds.Contains(stepId))
                {
                    try
                    {
                        await client.DeleteStep(stepId).ConfigureAwait(false);
                    }
                    catch (StepikApiException e)
                    {
                        results.Error("Can't delete step: " + e.Message);
                    }
                }
                else
                {
                    try
                    {
                        await client.MoveStep(stepId, newPosition + 1).ConfigureAwait(false);

                        // Increment newPosition only if success
                        newPosition++;
                    }
                    catch (StepikApiException e)
                    {
                        results.Error("Can't move step: " + e.Message);
                    }
                }
            }
        }
示例#2
0
 public Task <StepikApiLesson> UploadLesson(StepikApiLesson lesson)
 {
     return(Post(lesson));
 }