Initial import
This commit is contained in:
+20
@@ -0,0 +1,20 @@
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using MinAttest.Application.Abstractions;
|
||||
|
||||
namespace MinAttest.Application.Features.Employers.Commands;
|
||||
|
||||
public record DeleteEmployerUserCommand(Guid EmployerId, Guid UserId) : IRequest<bool>;
|
||||
|
||||
public class DeleteEmployerUserCommandHandler(IAppDbContext db) : IRequestHandler<DeleteEmployerUserCommand, bool>
|
||||
{
|
||||
public async Task<bool> 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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user