// GET api/values/5 public CoachingCourseDTO Get(Guid id) { var coachingCourseRepository = new CoachingCourseRepositoryDocumentDB(); return(CoachingCourseDTOConverter.ConvertToDTO( coachingCourseRepository.GetItems(i => i.Id == id).SingleOrDefault())); }
public void CreateCoachingCourse() { var courseName = "Service test course"; //Create the course _coachingCourseService.CreateNewCoachingCourse(courseName); //Check if we can find it, via another repository var repo = new CoachingCourseRepositoryDocumentDB(); var foundCourse = repo.GetItems(c => c.Name == courseName).Single(); Assert.IsNotNull(foundCourse); }
public void CreateAndFindNewCourse() { var courseName = "Test coaching course"; var courseRepo = new CoachingCourseRepositoryDocumentDB(); var course = new CoachingCourse(courseName); courseRepo.CreateCoachingCourse(course); courseRepo.SaveCoachingCourse(course); courseRepo = new CoachingCourseRepositoryDocumentDB(); var foundCourses = courseRepo.GetItems(c => c.Name == courseName).Single(); Assert.IsNotNull(foundCourses); }
public void AddModuleToCourse() { var courseName = "Course with modules"; var courseRepo = new CoachingCourseRepositoryDocumentDB(); var course = new CoachingCourse(courseName); courseRepo.CreateCoachingCourse(course); var introduction = new CoachingModuleResource() { RevisionHistory = new ResourseRevisionHistoryReference(), Content = "<h1><Overskrift her></h1> <p><Kort tekst her></p> <div data-oembed-url='https://vimeo.com/ricardonilsson/coachingwill'> <div style='left: 0px; width: 100%; height: 0px; position: relative; padding-bottom: 56.2493%;'><iframe allowfullscreen='true' frameborder='0' mozallowfullscreen='true' src='//player.vimeo.com/video/77308630?byline=0&badge=0&portrait=0&title=0' style='top: 0px; left: 0px; width: 100%; height: 100%; position: absolute;' webkitallowfullscreen='true'></iframe></div> </div> <h2><Overskrift, start på udvidet intro></h2> <p><Intro her></p> <h2><Overskrift, eksterne henvisninger></h2> <p><a href='http://wikipedia.org'><Eksempel på link></a></p>" }; var exercise = new CoachingModuleExerciseResource() { RevisionHistory = new ResourseRevisionHistoryReference(), Elements = new List <ResourceExerciseElement>() { new ResourceExerciseElement("<h1><Overskrift her></h1> <p><Kort tekst her, efterfulgt af ></p> <SortableList/>") } }; var reflection = new CoachingModuleExerciseResource() { RevisionHistory = new ResourseRevisionHistoryReference(), Elements = new List <ResourceExerciseElement>() { new ResourceExerciseElement("<h1><Overskrift her></h1> <p><Kort tekst her></p> <h2> </h2>") } }; var module = new CoachingModule ( "My coaching module", introduction, exercise, reflection ); course.AddCoachingModule(module); courseRepo.SaveCoachingCourse(course); courseRepo = new CoachingCourseRepositoryDocumentDB(); var foundCourses = courseRepo.GetItems(c => c.Name == courseName).Single(); Assert.IsNotNull(foundCourses); }
public void AdmitUsertoCourse() { var courseRepo = new CoachingCourseRepositoryDocumentDB(); var userRepo = new UserRepositoryDocumentDB(); var foundUsr = userRepo.GetUserById(new Guid("e65bed30-1e7e-4920-9ee4-b880fe9034e5")); var coachingCourseService = new CoachingCourseService( courseRepo, new ModuleResourceRepositoryDocumentDb(), new CoachingModuleRepositoryDocumentDB(), new CoachnigModuleExerciseResourceRepositoryDocumentDB(), new UserRepositoryDocumentDB()); var courseName = "Better ways course"; //Get course var course = courseRepo.GetItems(i => i.Name == courseName).Last(); // _coachingCourseService.CreateNewCoachingCourse(courseName); coachingCourseService.AdmitUserToCourse(foundUsr, course); }
public void UpdateModuleResource() { var courseName = "Service test course with updated module"; //Create the course var course = _coachingCourseService.CreateNewCoachingCourse(courseName); var coachingModule = _coachingCourseService.CreateNewModuleInCourse(course, "Some module", 0); var newResource = new CoachingModuleResource() { Content = "En meget kortere tekst", RevisionHistory = new ResourseRevisionHistoryReference() { ReferenceId = coachingModule.Introduction.RevisionHistoryReferenceId } }; _coachingCourseService.UpdateModuleResurce(coachingModule, newResource); var courseRepo = new CoachingCourseRepositoryDocumentDB(); var resourceRepo = new ModuleResourceRepositoryDocumentDb(); var moduleRepo = new CoachingModuleRepositoryDocumentDB(); var foundCourse = courseRepo.GetItems(i => i.Id == course.Id).Single(); var foundModule = moduleRepo.GetModuleById(foundCourse.Modules[0].ModuleReferenceId); var foundIntroductionResource = resourceRepo.GetResourceById(foundModule.Introduction.ResourceReferenceId); Assert.AreEqual(foundCourse.Modules.Count, 1); Assert.AreEqual(foundIntroductionResource.Content, "En meget kortere tekst"); resourceRepo = new ModuleResourceRepositoryDocumentDb(); var foundResources = resourceRepo.GetItems(i => i.RevisionHistory.ReferenceId == foundModule.Introduction.RevisionHistoryReferenceId); Assert.AreEqual(foundResources.OrderBy(v => v.Version).ToList()[0].Version, 1); Assert.AreEqual(foundResources.OrderBy(v => v.Version).ToList()[1].Version, 2); Assert.AreNotEqual(foundResources.OrderBy(v => v.Version).ToList()[0].Content, "En meget kortere tekst"); Assert.AreEqual(foundResources.OrderBy(v => v.Version).ToList()[1].Content, "En meget kortere tekst"); }
public void UpdatePromiseExerciseInstructionText() { var courseName = "Better ways course"; //Create the course var courseRep = new CoachingCourseRepositoryDocumentDB(); var moduleRep = new CoachingModuleRepositoryDocumentDB(); var resourceRep = new CoachnigModuleExerciseResourceRepositoryDocumentDB(); var course = courseRep.GetItems(c => c.Name == courseName).Single(); var modules = moduleRep.GetItemsWithIds(course.Modules.Select(m => m.ModuleReferenceId)).ToList(); var resources = resourceRep.GetItemsWithIds(modules.SelectMany(m => new[] { m.Exercise.ResourceReferenceId, m.Reflection.ResourceReferenceId })).ToList(); var goalExercises = resources.SelectMany(r => r.Elements.Where(el => el.Exercise != null && el.Exercise.ExerciseClassName == "Promise").Select(el => new { Resource = r, Exercise = el }) ).ToList(); foreach (var goalExercise in goalExercises) { goalExercise.Exercise.Exercise.InstrunctionContent = new List <string>() { "<p>Før vi går videre skal du give dig selv et mål til næste modul</p>\n" }; resourceRep.SaveItem(goalExercise.Resource); } }