public Task <string> CreateCollectorConfigAsync(CreateCollectorConfigCommand command) { var newConfig = new CollectorConfigStored() { Id = CollectorConfigStored.CreateId(), DisplayName = command.DisplayName, SchedulerAgentId = command.SchedulerAgentId }; newConfig.ValidateAndThrow(); _collectorConfigRepository.Store(newConfig); return(Task.FromResult(newConfig.Id)); }
public async Task Create_EmptyConfig_Success() { var store = NewDocumentStore(configureStore: ConfigureTestStore); var uow = new UnitOfWork(store); var configRepository = new CollectorConfigRepository(uow); var collectorConfigService = new CollectorConfigService(configRepository); var command = new CreateCollectorConfigCommand() { DisplayName = "Test", SchedulerAgentId = "default" }; uow.OpenSession(); var id = await collectorConfigService.CreateCollectorConfigAsync(command); uow.SaveChanges(); using (var session = store.OpenSession()) { var loadedConfig = session.Load <CollectorConfigStored>(id); loadedConfig.Should().NotBeNull(); loadedConfig.DisplayName.Should().BeEquivalentTo(command.DisplayName); } }
public async Task <ActionResult <string> > CreateCollectorConfig([FromBody] CreateCollectorConfigCommand command) { var id = await _collectorConfigService.CreateCollectorConfigAsync(command); return(Ok(id)); }