using Indotalent.Infrastructure.Database; using MediatR; using Microsoft.EntityFrameworkCore; namespace Indotalent.Features.Thirdparty.Customer.Cqrs; public record DeleteCustomerContactCommand(string Id) : IRequest; public class DeleteCustomerContactHandler : IRequestHandler { private readonly AppDbContext _context; public DeleteCustomerContactHandler(AppDbContext context) => _context = context; public async Task Handle(DeleteCustomerContactCommand request, CancellationToken cancellationToken) { var entity = await _context.CustomerContact .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken); if (entity == null) { return false; } _context.CustomerContact.Remove(entity); await _context.SaveChangesAsync(cancellationToken); return true; } }