Пример #1
0
        public async Task <bool> Handle(RemoveIdentityResourceCommand request, CancellationToken cancellationToken)
        {
            if (!request.IsValid())
            {
                NotifyValidationErrors(request);
                return(false);
            }

            var savedClient = await _identityResourceRepository.GetByName(request.Resource.Name);

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

                return(false);
            }

            _identityResourceRepository.Remove(savedClient.Id);

            if (Commit())
            {
                await Bus.RaiseEvent(new IdentityResourceRemovedEvent(request.Resource.Name));

                return(true);
            }
            return(false);
        }