public async Task <bool> Handle(SaveApiSecretCommand request, CancellationToken cancellationToken)
        {
            if (!request.IsValid())
            {
                NotifyValidationErrors(request);
                return(false);
            }

            var savedApi = await _apiResourceRepository.GetByName(request.ResourceName);

            if (savedApi == null)
            {
                await Bus.RaiseEvent(new DomainNotification("Api", "Api not found"));

                return(false);
            }

            var secret = request.ToEntity(savedApi);

            _apiSecretRepository.Add(secret);

            if (await Commit())
            {
                await Bus.RaiseEvent(new ApiSecretSavedEvent(request.Id, request.ResourceName));

                return(true);
            }
            return(false);
        }
        public async Task Handle(SaveApiSecretCommand request, CancellationToken cancellationToken)
        {
            if (!request.IsValid())
            {
                NotifyValidationErrors(request);
                return;
            }

            var savedClient = await _apiResourceRepository.GetByName(request.ResourceName);

            if (savedClient == null)
            {
                await Bus.RaiseEvent(new DomainNotification("1", "Client not found"));

                return;
            }

            var secret = new ApiSecret
            {
                ApiResource = savedClient,
                Description = request.Description,
                Expiration  = request.Expiration,
                Type        = request.Type,
                Value       = request.GetValue()
            };

            _apiSecretRepository.Add(secret);

            if (Commit())
            {
                await Bus.RaiseEvent(new ApiSecretSavedEvent(request.Id, request.ResourceName));
            }
        }