public async Task <IActionResult> UpdateAsync([FromRoute] Guid scopeId, [FromBody] ScopeRequestDto dto) { Scope scope; if (this.UserHasScope(ScopeScopes.Admin)) { scope = await _updateScopeService.UpdateAsync(dto.ToScope(scopeId)); } else { scope = await _updateScopeService.UpdateAsync(dto.ToScope(scopeId), this.GetUserId()); } var updated = ScopeResponseDto.FromScope(scope); return(Ok(updated)); }
public async Task <IActionResult> CreateAsync([FromBody] ScopeRequestDto dto) { Scope scope; if (this.UserHasScope(ScopeScopes.Admin)) { scope = await _addScopeService.AddAsync(dto.ToScope()); } else { scope = await _addScopeService.AddAsync(dto.ToScope(), this.GetUserId()); } var created = ScopeResponseDto.FromScope(scope); return(Created($"{_siteSettings.ListenUri}/scopes/{scope.ScopeId}", created)); }