Ejemplo n.º 1
0
        public async Task <bool> Handle(UpdateIdentityResourceCommand 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);
            }

            var irs = request.Resource.ToEntity();

            irs.Id = savedClient.Id;
            await _identityResourceRepository.UpdateWithChildrens(irs);

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

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