Standardize usage of RecActionViewDto across the codebase: - Update pipeline behaviors, mapping profiles, and commands to use RecActionViewDto. - Remove RecActionDto and introduce RecActionViewDto with equivalent properties and methods. - Adjust query handlers and related interfaces to work with RecActionViewDto. This clarifies DTO usage and aligns the model with domain intent.
24 lines
768 B
C#
24 lines
768 B
C#
using MediatR;
|
|
using ReC.Application.Common.Dto;
|
|
using ReC.Application.Common.Interfaces;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace ReC.Application.Common.Behaviors;
|
|
|
|
public class BodyQueryBehavior<TRequest, TResponse>(IRecDbContext dbContext) : IPipelineBehavior<TRequest, TResponse>
|
|
where TRequest : RecActionViewDto
|
|
where TResponse : notnull
|
|
{
|
|
public async Task<TResponse> Handle(TRequest action, RequestHandlerDelegate<TResponse> next, CancellationToken cancel)
|
|
{
|
|
if (action.BodyQuery is null)
|
|
return await next(cancel);
|
|
|
|
var result = await dbContext.BodyQueryResults.FromSqlRaw(action.BodyQuery).SingleOrDefaultAsync(cancel);
|
|
|
|
action.Body = result?.RawBody;
|
|
|
|
return await next(cancel);
|
|
}
|
|
}
|