using Application.Abstractions.Data; using Application.Abstractions.Messaging; using Domain.Entities.Donations.ValueObject; namespace Application.Features.Api.DonationRemote.IgnoreAlert; internal sealed class Handler(IAppDbContext db) : ICommandHandler { public async Task Handle(Command request, CancellationToken ct) { var alert = await db.DonationAlert.FindAsync([request.AlertID], ct); if (alert is null) { throw new KeyNotFoundException("알림을 찾을 수 없습니다."); } if (alert.Status == AlertStatus.Playing) { throw new InvalidOperationException("재생 중인 알림은 무시할 수 없습니다."); } alert.MarkIgnored(); await db.SaveChangesAsync(ct); } }