using Application.Abstractions.Data; using Application.Abstractions.Messaging; using Microsoft.EntityFrameworkCore; using SharedKernel.Results; namespace Application.Features.Api.Developers.Tokens.ListPats; internal sealed class Handler(IAppDbContext db) : IQueryHandler> { public async Task> Handle(Query request, CancellationToken ct) { var items = await db.ApiPersonalAccessToken .Where(c => c.OwnerMemberID == request.OwnerMemberID) .OrderByDescending(c => c.CreatedAt) .Select(c => new PatSummary( c.ID, c.Name, c.TokenHint, c.ScopesCsv, c.CreatedAt, c.ExpiresAt, c.LastUsedAt, c.RevokedAt )) .ToListAsync(ct); return Result.Success(new Response(items)); } }