Refactor validation behavior and update result view command
Refactored ValidationBehavior to use C# 12 primary constructors and file-scoped namespaces, simplifying the Handle method logic. Updated CreateResultViewCommand to implement IAuthScoped and IRequest, replaced AddedWho with a non-serialized Scope property, and added necessary usings and namespace.
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
using FluentValidation;
|
||||
using MediatR;
|
||||
|
||||
namespace ReC.Application.Common.Behaviors
|
||||
{
|
||||
public class ValidationBehavior<TRequest, TResponse>(IEnumerable<IValidator<TRequest>> validators) : IPipelineBehavior<TRequest, TResponse>
|
||||
namespace ReC.Application.Common.Behaviors;
|
||||
|
||||
public class ValidationBehavior<TRequest, TResponse>(IEnumerable<IValidator<TRequest>> validators) : IPipelineBehavior<TRequest, TResponse>
|
||||
where TRequest : notnull
|
||||
{
|
||||
{
|
||||
public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TResponse> next, CancellationToken cancel)
|
||||
{
|
||||
if (validators.Any())
|
||||
@@ -26,5 +26,4 @@ namespace ReC.Application.Common.Behaviors
|
||||
}
|
||||
return await next(cancel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
Reference in New Issue
Block a user