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>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user