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> FindAsync([FromRoute] Guid scopeId) { Scope scope; if (this.UserHasScope(ScopeScopes.Admin)) { scope = await _findScopeService.FindAsync(scopeId); } else { scope = await _findScopeService.FindAsync(scopeId, this.GetUserId()); } var found = ScopeResponseDto.FromScope(scope); return(Ok(found)); }
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)); }