50828d23ec
- Consolidate unit of work implementation with NotificationUnitOfWork. - Refactor repositories to use NotificationBaseRepository for consistency. - Simplify request handlers by removing IUnitOfWork dependency. - Update related tests and service registration.
24 lines
696 B
C#
24 lines
696 B
C#
using HrynCo.NotificationService.Services.Logging;
|
|
using MediatR;
|
|
using Serilog;
|
|
|
|
namespace HrynCo.NotificationService.Services.Core;
|
|
|
|
public abstract class RequestHandler<TRequest, TResponse> : IRequestHandler<TRequest, TResponse>
|
|
where TRequest : IRequest<TResponse>
|
|
{
|
|
protected RequestHandler(IContextualSerilogLogger<TRequest> logger)
|
|
{
|
|
Logger = logger.Logger;
|
|
}
|
|
|
|
protected ILogger Logger { get; }
|
|
|
|
public Task<TResponse> Handle(TRequest request, CancellationToken cancellationToken)
|
|
{
|
|
return DoOnHandle(request, cancellationToken);
|
|
}
|
|
|
|
protected abstract Task<TResponse> DoOnHandle(TRequest request, CancellationToken cancellationToken);
|
|
}
|