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); }
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)); } }
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()); }