public async Task <IActionResult> GetApplicationsAsync([FromRoute] Guid userId) { List <Application> applications; if (this.UserHasScope(UserScopes.Admin) || userId == this.GetUserId()) { applications = await _getApplicationsService.GetByUserIdAsync(userId); } else { throw new ForbiddenException(); } var found = applications.Select(a => ApplicationResponseDto.FromApplication(a, false)); return(Ok(found)); }
public async Task <IActionResult> GetAsync() { List <Application> applications; if (this.UserHasScope(ApplicationScopes.Admin)) { applications = await _getApplicationsService.GetAllAsync(); } else { applications = await _getApplicationsService.GetByUserIdAsync(this.GetUserId()); } var found = applications.Select(ApplicationResponseDto.FromApplication); return(Ok(found)); }