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,37 @@
using MediatR;
using Microsoft.EntityFrameworkCore;
using MinAttest.Contracts.Attests;
using MinAttest.Contracts.Persons;
using MinAttest.Application.Abstractions;
namespace MinAttest.Application.Features.Persons.Queries;
public record GetPersonQuery(Guid Id) : IRequest<PersonResponse?>;
public class GetPersonQueryHandler(IAppDbContext db) : IRequestHandler<GetPersonQuery, PersonResponse?>
{
public async Task<PersonResponse?> Handle(GetPersonQuery request, CancellationToken cancellationToken)
{
var person = await db.Persons
.Where(p => p.Id == request.Id)
.Select(p => new PersonResponse(
p.Id,
p.NationalIdHash,
p.Email,
p.Phone,
p.Attests
.Select(a => new AttestSummary(
a.Id,
a.Employer != null ? a.Employer.Name : string.Empty,
a.Title,
a.From,
a.To,
a.Status == Domain.Entities.AttestStatus.Issued
))
.ToList()
))
.FirstOrDefaultAsync(cancellationToken);
return person;
}
}