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

            var savedClient = await _apiResourceRepository.GetResource(request.OldResourceName);

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

                return(false);
            }

            var irs = request.Resource.ToEntity();

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

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

                return(true);
            }
            return(false);
        }
Esempio n. 2
0
        public async Task ShouldNotUpdateResourceWhenNameIsntProvided()
        {
            var command = new UpdateApiResourceCommand(new IdentityServer4.Models.ApiResource());


            var result = await _commandHandler.Handle(command, _tokenSource.Token);

            Assert.False(result);
            _uow.Verify(v => v.Commit(), Times.Never);
        }
        public Task <bool> Update(string id, ApiResource model)
        {
            var command = new UpdateApiResourceCommand(model, id);

            return(Bus.SendCommand(command));
        }