initial commit

This commit is contained in:
2026-07-21 14:22:06 +07:00
commit 2d7959f202
572 changed files with 45295 additions and 0 deletions
@@ -0,0 +1,27 @@
using Indotalent.Infrastructure.Database;
using MediatR;
using Microsoft.EntityFrameworkCore;
namespace Indotalent.Features.Payroll.Deduction.Cqrs;
public record DeleteDeductionByIdRequest(string Id);
public record DeleteDeductionByIdCommand(DeleteDeductionByIdRequest Data) : IRequest<bool>;
public class DeleteDeductionByIdHandler : IRequestHandler<DeleteDeductionByIdCommand, bool>
{
private readonly AppDbContext _context;
public DeleteDeductionByIdHandler(AppDbContext context) => _context = context;
public async Task<bool> Handle(DeleteDeductionByIdCommand request, CancellationToken cancellationToken)
{
var entity = await _context.Deduction
.FirstOrDefaultAsync(x => x.Id == request.Data.Id, cancellationToken);
if (entity == null) return false;
_context.Deduction.Remove(entity);
return await _context.SaveChangesAsync(cancellationToken) > 0;
}
}