public async Task HandleAsync(RequestNewApiKey command)
        {
            var featureAvailable = await _userFeaturesManager
                                   .IsFeatureIfAvailableAsync(command.UserId, FeatureType.AddApiKey);

            if (!featureAvailable)
            {
                await _bus.PublishAsync(new FeatureRejected(command.Request.Id,
                                                            command.UserId, FeatureType.AddApiKey.ToString(),
                                                            "API key limit reached."));

                return;
            }

            await _bus.PublishAsync(new CreateApiKey
            {
                ApiKeyId = command.ApiKeyId,
                UserId   = command.UserId,
                Request  = command.Request
            });
        }
        public async Task HandleAsync(RequestNewOrganization command)
        {
            var featureAvailable = await _userFeaturesManager
                                   .IsFeatureIfAvailableAsync(command.UserId, FeatureType.AddOrganization);

            if (!featureAvailable)
            {
                await _bus.PublishAsync(new FeatureRejected(command.Request.Id,
                                                            command.UserId, FeatureType.AddOrganization.ToString(),
                                                            "Organization limit reached."));

                return;
            }

            await _bus.PublishAsync(new CreateOrganization
            {
                OrganizationId = command.OrganizationId,
                UserId         = command.UserId,
                Name           = command.Name,
                Description    = command.Description,
                Request        = command.Request
            });
        }
Beispiel #3
0
        public async Task HandleAsync(RequestNewWarden command)
        {
            var featureAvailable = await _userFeaturesManager
                                   .IsFeatureIfAvailableAsync(command.UserId, FeatureType.AddWarden);

            if (!featureAvailable)
            {
                await _bus.PublishAsync(new FeatureRejected(command.Request.Id,
                                                            command.UserId, FeatureType.AddWarden.ToString(),
                                                            "Warden limit reached."));

                return;
            }

            await _bus.PublishAsync(new CreateWarden
            {
                UserId         = command.UserId,
                Name           = command.Name,
                WardenId       = command.WardenId,
                OrganizationId = command.OrganizationId,
                Enabled        = command.Enabled,
                Request        = command.Request
            });
        }
Beispiel #4
0
        public async Task HandleAsync(RequestWardenCheckResultProcessing command)
        {
            var featureAvailable = await _userFeaturesManager
                                   .IsFeatureIfAvailableAsync(command.UserId, FeatureType.AddWardenCheck);

            if (!featureAvailable)
            {
                await _bus.PublishAsync(new FeatureRejected(command.Request.Id,
                                                            command.UserId, FeatureType.AddWardenCheck.ToString(),
                                                            "Warden check limit reached."));

                return;
            }

            await _bus.PublishAsync(new ProcessWardenCheckResult
            {
                UserId         = command.UserId,
                CreatedAt      = command.CreatedAt,
                OrganizationId = command.OrganizationId,
                WardenId       = command.WardenId,
                Check          = command.Check,
                Request        = command.Request
            });
        }