예제 #1
0
        public async Task <IActionResult> DeleteApiScope([FromRoute] Guid id, [FromRoute] Guid scopeId)
        {
            var command = new DeleteApiScopeCommand {
                Id = scopeId, ApiResourceId = id
            };
            await _mediator.Send(command);

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

            api.DeleteScope(message.Id);

            await _repository.SaveAsync(api);

            return(true);
        }
예제 #3
0
        public async Task <IActionResult> DeleteApiScope(DeleteApiScopeCommand command)
        {
            try
            {
                var client = await _mediator.Send(command);

                return(Ok());
            }
            catch (KeyNotFoundException ex)
            {
                return(NotFound());
            }
            catch (ArgumentException argumentException)
            {
                return(BadRequest(argumentException.Message));
            }
        }