| | | 1 | | using RoleRadar.Application.Abstractions; |
| | | 2 | | |
| | | 3 | | namespace RoleRadar.Application.Integrity; |
| | | 4 | | |
| | | 5 | | public sealed record IntegrityAnomalyDto( |
| | | 6 | | string Kind, |
| | | 7 | | string Description, |
| | | 8 | | Guid SourceId, |
| | | 9 | | Guid? TargetId = null); |
| | | 10 | | |
| | | 11 | | public sealed record VerifyIntegrityResultDto( |
| | | 12 | | int AnomalyCount, |
| | | 13 | | IReadOnlyList<IntegrityAnomalyDto> Anomalies); |
| | | 14 | | |
| | | 15 | | public sealed record VerifyIntegrityQuery(string? OwnerId = null) : IQuery<VerifyIntegrityResultDto>; |
| | | 16 | | |
| | | 17 | | public interface IIntegrityRepository |
| | | 18 | | { |
| | | 19 | | Task<Result<VerifyIntegrityResultDto>> VerifyIntegrityAsync(string? ownerId = null, CancellationToken cancellationTo |
| | | 20 | | } |
| | | 21 | | |
| | | 22 | | public sealed class VerifyIntegrityQueryHandler : IQueryHandler<VerifyIntegrityQuery, VerifyIntegrityResultDto> |
| | | 23 | | { |
| | | 24 | | private readonly IIntegrityRepository _integrityRepository; |
| | | 25 | | |
| | 10 | 26 | | public VerifyIntegrityQueryHandler(IIntegrityRepository integrityRepository) |
| | | 27 | | { |
| | 10 | 28 | | _integrityRepository = integrityRepository ?? throw new ArgumentNullException(nameof(integrityRepository)); |
| | 10 | 29 | | } |
| | | 30 | | |
| | | 31 | | public Task<Result<VerifyIntegrityResultDto>> HandleAsync(VerifyIntegrityQuery query, CancellationToken cancellation |
| | | 32 | | { |
| | 10 | 33 | | ArgumentNullException.ThrowIfNull(query); |
| | 10 | 34 | | return _integrityRepository.VerifyIntegrityAsync(query.OwnerId, cancellationToken); |
| | | 35 | | } |
| | | 36 | | } |