Files
hrynco-notification-service/HrynCo.NotificationService.Services/Core/RequestHandler.cs
T
Anatolii Grynchuk a03d2269a6 feat: add MediatR handlers for template and channel CRUD
- ServiceResult<T>, ServiceError, ServiceErrorCode, Unit, ServiceResultHelper in Services/Core
- RequestHandler<TRequest, TResponse> base class (MediatR-adapted, DoOnHandle pattern)
- EmailTemplate handlers: Create, Update, Delete, Get, GetByService
- EmailChannel handlers: Create, Update, Delete, Get, GetByService

Ref: IT-628

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-02 01:07:13 +03:00

25 lines
830 B
C#

using HrynCo.NotificationService.DAL.Abstract;
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, IUnitOfWork unitOfWork)
{
Logger = logger.Logger;
UnitOfWork = unitOfWork;
}
protected ILogger Logger { get; }
protected IUnitOfWork UnitOfWork { get; }
public Task<TResponse> Handle(TRequest request, CancellationToken cancellationToken) =>
DoOnHandle(request, cancellationToken);
protected abstract Task<TResponse> DoOnHandle(TRequest request, CancellationToken cancellationToken);
}