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 static UserResponseDto FromUser(User user, bool includeChildren) { var dto = new UserResponseDto { user_id = user.UserId, username = user.Username, created_date = user.CreatedDateTime, modified_date = user.ModifiedDateTime }; if (includeChildren) { dto.applications = user.Applications?.Select(a => ApplicationResponseDto.FromApplication(a, false)).ToList(); } return(dto); }