initial commit

This commit is contained in:
2026-07-21 14:08:10 +07:00
commit f7cf118326
533 changed files with 41762 additions and 0 deletions
@@ -0,0 +1,44 @@
using Indotalent.ConfigBackEnd.Exceptions;
using Indotalent.Infrastructure.Database;
using MediatR;
using Microsoft.EntityFrameworkCore;
namespace Indotalent.Features.Payroll.Payrolls.Cqrs;
public class DeletePayrollProcessByIdRequest
{
public string? Id { get; set; }
}
public class DeletePayrollProcessByIdResponse
{
public string? Id { get; set; }
}
public record DeletePayrollProcessByIdCommand(DeletePayrollProcessByIdRequest Data) : IRequest<DeletePayrollProcessByIdResponse>;
public class DeletePayrollProcessByIdHandler : IRequestHandler<DeletePayrollProcessByIdCommand, DeletePayrollProcessByIdResponse>
{
private readonly AppDbContext _context;
public DeletePayrollProcessByIdHandler(AppDbContext context) => _context = context;
public async Task<DeletePayrollProcessByIdResponse> Handle(DeletePayrollProcessByIdCommand request, CancellationToken cancellationToken)
{
var entity = await _context.PayrollProcess
.FirstOrDefaultAsync(x => x.Id == request.Data.Id, cancellationToken);
if (entity == null)
{
throw new NotFoundException("Payroll Process", request.Data.Id ?? string.Empty);
}
_context.PayrollProcess.Remove(entity);
await _context.SaveChangesAsync(cancellationToken);
return new DeletePayrollProcessByIdResponse
{
Id = entity.Id
};
}
}