using MediatR; using Microsoft.EntityFrameworkCore; using MinAttest.Application.Abstractions; using MinAttest.Contracts.ShareLinks; namespace MinAttest.Application.Features.ShareLinks.Queries; public record ListShareLinksQuery(Guid AttestId) : IRequest>; public class ListShareLinksQueryHandler(IAppDbContext db) : IRequestHandler> { public async Task> Handle(ListShareLinksQuery request, CancellationToken cancellationToken) { return await db.ShareLinks.AsNoTracking() .Where(l => l.AttestId == request.AttestId && l.RevokedAt == null) .OrderBy(l => l.ExpiresAt) .Select(l => new ShareLinkResponse(l.Id, l.Code, new Uri($"https://app.example/verify/{l.Code}"), l.ExpiresAt, l.OneTime)) .ToListAsync(cancellationToken); } }