Handler.cs 644 B

12345678910111213141516171819202122
  1. using Application.Abstractions.Data;
  2. using Application.Abstractions.Messaging;
  3. using Microsoft.EntityFrameworkCore;
  4. namespace Application.Features.Api.DonationAlert.DeleteConfig;
  5. internal sealed class Handler(IAppDbContext db) : ICommandHandler<Command>
  6. {
  7. public async Task Handle(Command request, CancellationToken ct)
  8. {
  9. var config = await db.DonationAlertConfig
  10. .FirstOrDefaultAsync(c => c.ID == request.ID && c.ChannelID == request.ChannelID, ct);
  11. if (config is null)
  12. {
  13. return;
  14. }
  15. db.DonationAlertConfig.Remove(config);
  16. await db.SaveChangesAsync(ct);
  17. }
  18. }