Initial import

This commit is contained in:
Stein Helge Riise
2025-11-17 08:32:46 +01:00
commit ede31fbb7e
129 changed files with 9514 additions and 0 deletions
@@ -0,0 +1,22 @@
using MediatR;
using Microsoft.EntityFrameworkCore;
using MinAttest.Application.Abstractions;
using MinAttest.Contracts.Attests;
using MinAttest.Domain.Entities;
namespace MinAttest.Application.Features.Attests.Queries;
public record ListPersonAttestsQuery(Guid PersonId, int? Take) : IRequest<IReadOnlyList<AttestSummary>>;
public class ListPersonAttestsQueryHandler(IAppDbContext db) : IRequestHandler<ListPersonAttestsQuery, IReadOnlyList<AttestSummary>>
{
public async Task<IReadOnlyList<AttestSummary>> Handle(ListPersonAttestsQuery request, CancellationToken cancellationToken)
{
return await db.Attests.AsNoTracking().Include(a => a.Employer)
.Where(a => a.PersonId == request.PersonId)
.OrderByDescending(a => a.IssuedAt)
.Take(Math.Clamp(request.Take ?? 50, 1, 200))
.Select(a => new AttestSummary(a.Id, (a.Employer != null ? a.Employer.Name : string.Empty), a.Title, a.From, a.To, a.Status == AttestStatus.Issued))
.ToListAsync(cancellationToken);
}
}