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