using MediatR; using Microsoft.EntityFrameworkCore; using MinAttest.Application.Abstractions; namespace MinAttest.Application.Features.Employers.Commands; public record DeleteEmployerUserCommand(Guid EmployerId, Guid UserId) : IRequest; public class DeleteEmployerUserCommandHandler(IAppDbContext db) : IRequestHandler { public async Task Handle(DeleteEmployerUserCommand request, CancellationToken cancellationToken) { var user = await db.EmployerUsers.FirstOrDefaultAsync(u => u.Id == request.UserId && u.EmployerId == request.EmployerId, cancellationToken); if (user is null) return false; db.EmployerUsers.Remove(user); await db.SaveChangesAsync(cancellationToken); return true; } }