Esempio 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());
        }
Esempio n. 2
0
        public Task <IList <FeatureGroupDto> > HandleAsync(GetAllFeatureGroupsQuery query)
        {
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }

            return(_repository.GetAllAsync());
        }
        public async Task <IActionResult> GetAllAsync()
        {
            var featureGroups = await _repository.GetAllAsync();

            return(Ok(featureGroups));
        }