Ejemplo n.º 1
0
 public LectureController(IUmbracoMapper mapper, ISubscriptionsService subscriptions, ILecturesService lectures, ICoursesContentService coursesContentService)
 {
     _mapper                = mapper;
     _subscriptions         = subscriptions;
     _lectures              = lectures;
     _coursesContentService = coursesContentService;
 }
Ejemplo n.º 2
0
        public void GetLectureByExternalId_ReturnsNull_WhenLectureDoesntExist()
        {
            // Arrange
            List <Lecture> testLectures = new List <Lecture>
            {
                new Lecture {
                    ExternalId = 1, Id = 3123, Title = "Lecture 1"
                },
                new Lecture {
                    ExternalId = 2, Id = 4324, Title = "Lecture 2"
                }
            };

            IRepository <Lecture> repository = new RepositoryMock <Lecture>();

            testLectures.ForEach(lecture => repository.Add(lecture));

            ILecturesService service = SetupLecturesService(repository);

            int lectureId = 6;

            // Act
            Lecture returnedLecture = service.GetLectureByExternalId(lectureId);

            // Assert
            Assert.IsNull(returnedLecture);
        }
Ejemplo n.º 3
0
 public CourseController(ICoursesService courses, IUmbracoMapper mapper, ISubscriptionsService subscriptions, ILecturesService lectures, IAssessmentsService assessmentsService)
 {
     _courses            = courses;
     _mapper             = mapper;
     _subscriptions      = subscriptions;
     _lectures           = lectures;
     _assessmentsService = assessmentsService;
 }
Ejemplo n.º 4
0
 public LecturesController(
     ILecturesService lectureService,
     IAzureStorageBlob azureMediaService,
     UserManager <User> userManager)
 {
     this.lectureService    = lectureService;
     this.azureMediaService = azureMediaService;
     this.userManager       = userManager;
 }
Ejemplo n.º 5
0
 public LecturesController(
     ILecturesService lecturesService,
     IFilesService fileService,
     UserManager <ApplicationUser> userManager)
 {
     this.lecturesService = lecturesService;
     this.fileService     = fileService;
     this.userManager     = userManager;
 }
Ejemplo n.º 6
0
        public void GetLectureByExternalId_ThrowsArgumentOutOfRangeException_WhenLectureIdIsZero()
        {
            // Arrange
            ILecturesService service = SetupLecturesService();

            int lectureId = 0;

            // Act & Assert
            Assert.Throws <ArgumentOutOfRangeException>(() => service.GetLectureByExternalId(lectureId));
        }
Ejemplo n.º 7
0
        private void AddOrUpdateLecture(IEnumerable <IContent> content, Func <IContent, bool> isActive)
        {
            IContent lectureContent = content.FirstOrDefault(x => x.ContentType.Alias == nameof(DocumentTypes.Lecture));
            IContent moduleContent  = content.FirstOrDefault(x => x.ContentType.Alias == nameof(DocumentTypes.Module));

            if (lectureContent != null && lectureContent.HasIdentity)
            {
                ILecturesService lecturesService = DependencyResolver.Current.GetService(typeof(ILecturesService)) as ILecturesService;
                if (lecturesService == null)
                {
                    throw new InvalidOperationException("LecturesService failed to instantiate");
                }

                Lecture lecture = lecturesService.GetLectureByExternalId(lectureContent.Id);
                if (lecture == null)
                {
                    lecture = new Lecture
                    {
                        ExternalId = lectureContent.Id,
                        Title      = lectureContent.Name
                    };
                }

                IContent courseParentNode = lectureContent.Ancestors().FirstOrDefault(x => x.ContentType.Alias == nameof(DocumentTypes.Course));
                if (courseParentNode?.ContentType.Alias == nameof(DocumentTypes.Course))
                {
                    string courseId = (string)courseParentNode.Properties[(nameof(DocumentTypes.Course.CourseId))].Value;
                    if (string.IsNullOrWhiteSpace(courseId))
                    {
                        throw new ArgumentException($"Course with Id: {courseParentNode.Id} doesn't have a CourseId field present");
                    }

                    lecture.CourseId = int.Parse(courseId);
                }

                lecture.IsActive = isActive(lectureContent);
                lecturesService.AddOrUpdate(lecture);
            }
            else if (moduleContent != null)
            {
                ILecturesService lecturesService = DependencyResolver.Current.GetService(typeof(ILecturesService)) as ILecturesService;
                if (lecturesService == null)
                {
                    throw new InvalidOperationException("LecturesService failed to instantiate");
                }

                bool isModuleActive = isActive(moduleContent);
                foreach (IContent lect in moduleContent.Descendants().Where(x => x.ContentType.Alias == nameof(DocumentTypes.Lecture)))
                {
                    Lecture lecture = lecturesService.GetLectureByExternalId(lect.Id);
                    lecture.IsActive = isModuleActive && isActive(lect);
                    lecturesService.AddOrUpdate(lecture);
                }
            }
        }
Ejemplo n.º 8
0
 public AssessmentsService(IRepository <AssessmentRequest> assessmentRequests, IRepository <AssessmentSubmission> assessmentSubmissions, IMessageService messageService, ITaskRunner taskRunner, ILecturesService lecturesService, IApplicationSettings applicationSettings, IRepository <CourseSubscription> subscriptions, IRouteProvider routeProvider, ICertificatesService certificatesService, IRepository <Course> courses)
 {
     _assessmentRequests    = assessmentRequests;
     _assessmentSubmissions = assessmentSubmissions;
     _messageService        = messageService;
     _taskRunner            = taskRunner;
     _lecturesService       = lecturesService;
     _applicationSettings   = applicationSettings;
     _subscriptions         = subscriptions;
     _routeProvider         = routeProvider;
     _certificatesService   = certificatesService;
     _courses = courses;
 }
Ejemplo n.º 9
0
 public SubscriptionsService(IRepository <User> users, IRepository <CourseSubscription> courseSubscriptions, IRepository <Course> courses, ICoursesService coursesService, IUserService usersService, ILecturesService lectures, IAssessmentsService assessments, IMessageService messageService, IRepository <Payment> payments, IRouteProvider routeProvider, IOrdersService ordersService)
 {
     _users = users;
     _courseSubscriptions = courseSubscriptions;
     _courses             = courses;
     _coursesService      = coursesService;
     _usersService        = usersService;
     _lectures            = lectures;
     _assessments         = assessments;
     _messageService      = messageService;
     _payments            = payments;
     _routeProvider       = routeProvider;
     _ordersService       = ordersService;
 }
Ejemplo n.º 10
0
 public LecturesController(ILecturesService lecturesService)
 {
     this.lectures = lecturesService;
 }
Ejemplo n.º 11
0
 public LecturesController(ILecturesService service)
 {
     this.service = service;
 }
        private IAssessmentsService SetupAssessmentsService(
            IRepository <AssessmentRequest> assessmentRequests       = null,
            IRepository <AssessmentSubmission> assessmentSubmissions = null,
            IMessageService messageService                 = null,
            ITaskRunner taskRunner                         = null,
            ILecturesService lecturesService               = null,
            IApplicationSettings applicationSettings       = null,
            IRepository <CourseSubscription> subscriptions = null,
            IRouteProvider routeProvider                   = null,
            ICertificatesService certificatesService       = null,
            IRepository <Course> courses                   = null)
        {
            if (assessmentRequests == null)
            {
                assessmentRequests = new Mock <IRepository <AssessmentRequest> >().Object;
            }

            if (assessmentSubmissions == null)
            {
                assessmentSubmissions = new Mock <IRepository <AssessmentSubmission> >().Object;
            }

            if (messageService == null)
            {
                messageService = new Mock <IMessageService>().Object;
            }

            if (taskRunner == null)
            {
                taskRunner = new Mock <ITaskRunner>().Object;
            }

            if (lecturesService == null)
            {
                lecturesService = new Mock <ILecturesService>().Object;
            }

            if (applicationSettings == null)
            {
                applicationSettings = new Mock <IApplicationSettings>().Object;
            }

            if (subscriptions == null)
            {
                subscriptions = new Mock <IRepository <CourseSubscription> >().Object;
            }

            if (routeProvider == null)
            {
                routeProvider = new Mock <IRouteProvider>().Object;
            }

            if (certificatesService == null)
            {
                certificatesService = new Mock <ICertificatesService>().Object;
            }

            if (courses == null)
            {
                courses = new Mock <IRepository <Course> >().Object;
            }

            var service = new AssessmentsService(assessmentRequests, assessmentSubmissions, messageService, taskRunner, lecturesService, applicationSettings, subscriptions, routeProvider, certificatesService, courses);

            return(service);
        }
 public LectureBLController(ILecturesService lectureService, ILogger <LectureBLController> logger)//
 {
     _lectureService = lectureService;
     _logger         = logger;
     _logger.LogInformation("Index page says hello");
 }