예제 #1
0
        public async Task <bool> Handle(UpdateApiScopeCommand message, CancellationToken cancellationToken)
        {
            var api = await _repository.GetById(message.ApiResourceId) ?? throw new KeyNotFoundException();

            var scope = api.Scopes.FirstOrDefault(s => s.Id == message.Id) ?? throw new KeyNotFoundException();

            scope.Description = message.Description;

            await _repository.SaveAsync(api);

            return(true);
        }
예제 #2
0
        public async Task <IActionResult> PutApiScope([FromBody] UpdateApiScopeCommand command)
        {
            try
            {
                await _mediator.Send(command);

                return(Ok());
            }
            catch (KeyNotFoundException ex)
            {
                return(NotFound());
            }
            catch (ArgumentException argumentException)
            {
                return(BadRequest(argumentException.Message));
            }
        }
예제 #3
0
        public async Task <IActionResult> PutApiScope([FromRoute] Guid id, [FromRoute] Guid scopeId, [FromBody] UpdateApiScopeCommand command)
        {
            command.ApiResourceId = id;
            command.Id            = scopeId;

            await _mediator.Send(command);

            return(Ok());
        }