diff --git a/src/ReC.Application/Common/Behaviors/ValidationBehavior.cs b/src/ReC.Application/Common/Behaviors/ValidationBehavior.cs index 403e1e2..114f379 100644 --- a/src/ReC.Application/Common/Behaviors/ValidationBehavior.cs +++ b/src/ReC.Application/Common/Behaviors/ValidationBehavior.cs @@ -1,30 +1,29 @@ using FluentValidation; using MediatR; -namespace ReC.Application.Common.Behaviors +namespace ReC.Application.Common.Behaviors; + +public class ValidationBehavior(IEnumerable> validators) : IPipelineBehavior + where TRequest : notnull { - public class ValidationBehavior(IEnumerable> validators) : IPipelineBehavior - where TRequest : notnull + public async Task Handle(TRequest request, RequestHandlerDelegate next, CancellationToken cancel) { - public async Task Handle(TRequest request, RequestHandlerDelegate next, CancellationToken cancel) + if (validators.Any()) { - if (validators.Any()) - { - var context = new ValidationContext(request); + var context = new ValidationContext(request); - var validationResults = await Task.WhenAll( - validators.Select(v => - v.ValidateAsync(context, cancel))); + var validationResults = await Task.WhenAll( + validators.Select(v => + v.ValidateAsync(context, cancel))); - var failures = validationResults - .SelectMany(r => r.Errors) - .Where(f => f != null) - .ToList(); + var failures = validationResults + .SelectMany(r => r.Errors) + .Where(f => f != null) + .ToList(); - if (failures.Count != 0) - throw new ValidationException(failures); - } - return await next(cancel); + if (failures.Count != 0) + throw new ValidationException(failures); } + return await next(cancel); } } \ No newline at end of file diff --git a/src/ReC.Application/ResultViews/Commands/CreateResultViewCommand.cs b/src/ReC.Application/ResultViews/Commands/CreateResultViewCommand.cs index 0681acd..6036cef 100644 --- a/src/ReC.Application/ResultViews/Commands/CreateResultViewCommand.cs +++ b/src/ReC.Application/ResultViews/Commands/CreateResultViewCommand.cs @@ -1,6 +1,10 @@ -namespace ReC.Application.ResultViews.Commands; +using MediatR; +using ReC.Application.Common.Interfaces; +using System.Text.Json.Serialization; -public class CreateResultViewCommand +namespace ReC.Application.ResultViews.Commands; + +public class CreateResultViewCommand : IAuthScoped, IRequest { public required long ActionId { get; set; } @@ -10,5 +14,6 @@ public class CreateResultViewCommand public string? Body { get; set; } - public string AddedWho { get; set; } = null!; + [JsonIgnore] + public AuthScope Scope { get; } = new(); } \ No newline at end of file