using Brizco.Domain.MartenEntities.Notifications; namespace Brizco.Repository.MartenHandlers.Notifications; public class ReadNotificationCommandHandler : IRequestHandler { private readonly IMartenRepositoryWrapper _martenRepositoryWrapper; private readonly ICurrentUserService _currentUserService; public ReadNotificationCommandHandler(IMartenRepositoryWrapper martenRepositoryWrapper, ICurrentUserService currentUserService) { _martenRepositoryWrapper = martenRepositoryWrapper; _currentUserService = currentUserService; } public async Task Handle(ReadNotificationCommand request, CancellationToken cancellationToken) { var notification = await _martenRepositoryWrapper.SetRepository() .GetEntityAsync(request.Id, cancellationToken); if (notification == null) throw new BaseApiException(ApiResultStatusCode.NotFound,"Notification not found"); notification.IsRead = true; await _martenRepositoryWrapper.SetRepository() .AddOrUpdateEntityAsync(notification, cancellationToken); return true; } }