Ejemplo n.º 1
0
        public async Task <VoidResult> HandleAsync(InitializeTogglOnCommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }

            await _initializeDbRepository.CreateAsync();

            var namespaceCollectionTask     = _namespaceRepository.GetAllAsync();
            var environmentCollectionTask   = _environmentRepository.GetAllAsync();
            var featureGroupCollectionTask  = _featureGroupRepository.GetAllAsync();
            var featureToggleCollectionTask = _featureToggleRepository.GetAllAsync(command.Namespace, command.Environment);

            var namespaceCollection     = await namespaceCollectionTask;
            var environmentCollection   = await environmentCollectionTask;
            var featureGroupCollection  = await featureGroupCollectionTask;
            var featureToggleCollection = await featureToggleCollectionTask;

            var addNamespaceTask     = AddNamespaceIfNotExistsAsync(namespaceCollection, command.Namespace);
            var addEnvironmentTask   = AddEnvironmentIfNotExistsAsync(environmentCollection, command.Environment);
            var addFeatureGroupTask  = AddFeatureGroupIfNotExistsAsync(featureGroupCollection, command.FeatureGroups);
            var addFeatureToggleTask = AddFeatureToggleIfNotExistsAsync(featureToggleCollection, command.FeatureToggles);

            await addNamespaceTask;
            await addEnvironmentTask;
            await addFeatureGroupTask;
            await addFeatureToggleTask;

            return(new VoidResult());
        }
Ejemplo n.º 2
0
        public Task <IList <FeatureToggleDto> > HandleAsync(GetAllFeatureTogglesQuery query)
        {
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }

            return(_repository.GetAllAsync(query.Namespace, query.Environment));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> GetAllAsync()
        {
            var featureToggles = await _repository.GetAllAsync();

            return(Ok(featureToggles));
        }