using ChapterX.Domain.Repositories; using MediatR; using Microsoft.Extensions.Logging; namespace ChapterX.Application.Notification.Commands { public class DeleteHandler : IRequestHandler { private readonly INotificationRepository _notificationRepository; private readonly ILogger _logger; public DeleteHandler(INotificationRepository notificationRepository, ILogger logger) { _notificationRepository = notificationRepository; _logger = logger; } public async Task Handle(DeleteRequest request, CancellationToken cancellationToken) { var notification = await _notificationRepository.GetByIdAsync(request.Id, cancellationToken); if (notification is null) return new DeleteResponse(false); await _notificationRepository.DeleteAsync(notification, cancellationToken); return new DeleteResponse(true); } } }