예제 #1
0
        public async Task <bool> Handle(RemoveIdentityResourceCommand request, CancellationToken cancellationToken)
        {
            if (!request.IsValid())
            {
                NotifyValidationErrors(request);
                return(false);
            }

            var resource = await _identityResourceRepository.FirstOrDefaultAsync(r => r.Name == request.IdentityResource.Name);

            if (resource != null)
            {
                await _identityResourceRepository.RemoveAsync(resource);

                if (Commit())
                {
                    await _bus.RaiseEvent(new IdentityResourceRemovedEvent(resource.Id));

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