public async Task <IActionResult> CreateNewModule([FromBody] ModuleViewModel moduleViewModel) { try { var user = await GetUser(); var location = await _locationRepository.GetLocationById(moduleViewModel.LocationId); if (location.ApplicationUserId != user.Id) { return(BadRequest(new ErrorMessage(ErrorMessageResponses.UnAuthorizedModifyLocation))); } var module = new Module { LocationId = moduleViewModel.LocationId, Name = moduleViewModel.Name, IsMotionDetector = moduleViewModel.IsMotionDetector }; await _moduleRepository.CreateModule(module); return(Ok(moduleViewModel)); } catch (Exception ex) { Logger.LogError(ex.Message); return(BadRequest(new ErrorResponse(ex))); } }
private long CreateModule(ModuleGecreeerd @event, long cohortId) => _moduleRepository.CreateModule(new Module { ModuleCode = @event.ModuleCode, ModuleNaam = @event.ModuleNaam, CohortId = cohortId, Studiepunten = @event.AantalEc });
public Task <Domain.Entities.Module> Handle(CreateModule request, CancellationToken cancellationToken) { return(_moduleRepository.CreateModule(request.Token, request.Name, request.Description, request.GithubLink, request.Replacements, request.IsCore)); }
public async Task <IHttpActionResult> Upload(string name, string version) { try { Stream stream = await Request.Content.ReadAsStreamAsync(); _repository.CreateModule(name, version, stream); Module module = _repository.GetModule(name, version); return(Ok(module)); } catch (Exception e) { return(HandleUnexpectedException(10016, e)); } }
public async Task PostAsync([FromBody] ModuleApi module) { await repository.CreateModule(module); }
public static void Main(string[] args) { // add initial fake data for testing CourseApi course1 = new CourseApi { CourseId = "1", Name = "John Doe's course", ModuleIds = new List <string> { "987" } }; ModuleApi module1 = new ModuleApi { ModuleId = "987", Author = "John Doe", Title = "Agile Development", CourseIds = new List <string> { "1" }, Layout = new List <ModuleBaseContent> { new ModuleTextContent { Heading = "Motivation for Agile", Text = "This is why we want to do Agile" }, new ModuleImageContent { Link = "MyImageLink", Caption = "MyImageCaption" }, new ModuleVideoContent { Link = "MyVideoLink", Caption = "MyVideoCaption" }, new ModuleQuizContent { Link = "MyQuizLink" } } }; var host = BuildWebHost(args); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { IModuleRepository moduleRepository = services.GetRequiredService <IModuleRepository>(); moduleRepository.CreateModule(module1); ICourseRepository courseRepository = services.GetRequiredService <ICourseRepository>(); courseRepository.CreateCourse(course1); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occurred while seeding the database."); } } host.Run(); }
public ResponseModel CreateModule(Module module) { return(_moduleRepository.CreateModule(module)); }