namespace Health.Application.Notifications; public sealed class InAppNotificationService(IInAppNotificationRepository notifications) : IInAppNotificationService { private readonly IInAppNotificationRepository _notifications = notifications; public async Task> GetPendingAsync(Guid userId, CancellationToken ct) { var records = await _notifications.GetPendingAsync(userId, ct); return records.Select(ToDto).ToList(); } public async Task> GetHistoryAsync(Guid userId, CancellationToken ct) { var records = await _notifications.GetHistoryAsync(userId, ct); return records.Select(ToDto).ToList(); } public Task AcknowledgeAsync(Guid userId, Guid notificationId, CancellationToken ct) => _notifications.AcknowledgeAsync(userId, notificationId, ct); public Task MarkAllReadAsync(Guid userId, CancellationToken ct) => _notifications.MarkAllReadAsync(userId, ct); public Task DeleteAsync(Guid userId, Guid notificationId, CancellationToken ct) => _notifications.DeleteAsync(userId, notificationId, ct); private static InAppNotificationDto ToDto(InAppNotificationRecord record) => new( record.Id, record.Type, record.Title, record.Message, record.Severity, record.ActionType, record.ActionTargetId, record.IsRead, record.CreatedAt); }