Files
hrynco-notification-service/HrynCo.NotificationService.Services/TemplateDefinitions/GetNotificationServiceHandler.cs
T
agrynco 8e81572386 feat(notification): add admin rest management and deletion
Add revision-safe service and template APIs, channel mapping, and validated admin controls.

Ref: IT-1601
2026-10-17 22:51:01 +03:00

24 lines
1.3 KiB
C#

using HrynCo.NotificationService.DAL.Abstract.Repositories;
using HrynCo.NotificationService.Services.Core;
using HrynCo.NotificationService.Services.Logging;
using static HrynCo.NotificationService.Services.Core.ServiceResultHelper;
namespace HrynCo.NotificationService.Services.TemplateDefinitions;
internal sealed class GetNotificationServiceHandler(
IContextualSerilogLogger<GetNotificationServiceQuery> logger, INotificationServiceRepository services)
: RequestHandler<GetNotificationServiceQuery, ServiceResult<NotificationServiceDto>>(logger)
{
protected override async Task<ServiceResult<NotificationServiceDto>> DoOnHandle(GetNotificationServiceQuery request, CancellationToken cancellationToken)
{
if (request.ServiceId is null && string.IsNullOrWhiteSpace(request.Name))
return Failure<NotificationServiceDto>("An exact service name is required.", ServiceErrorCode.InvalidRequest);
var service = request.ServiceId is Guid id
? await services.GetAsync(id, cancellationToken)
: await services.GetByNameAsync(request.Name!, cancellationToken);
return service is null
? Failure<NotificationServiceDto>("Service not found.", ServiceErrorCode.NotFound)
: Success(NotificationServiceMapping.Map(service));
}
}