initial commit
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
using Indotalent.Infrastructure.Database;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Indotalent.Features.Payroll.Payrolls.Cqrs;
|
||||
|
||||
public class GetPayrollProcessListRequest
|
||||
{
|
||||
}
|
||||
|
||||
public class GetPayrollProcessListResponse
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public string? AutoNumber { get; set; }
|
||||
public string? PeriodName { get; set; }
|
||||
public DateTime FromDate { get; set; }
|
||||
public DateTime ToDate { get; set; }
|
||||
public int TotalEmployees { get; set; }
|
||||
public decimal TotalBasicSalary { get; set; }
|
||||
public decimal TotalIncome { get; set; }
|
||||
public decimal TotalDeduction { get; set; }
|
||||
public decimal TotalGross { get; set; }
|
||||
public decimal TotalTakeHomePay { get; set; }
|
||||
public string? Status { get; set; }
|
||||
public string? ProcessedBy { get; set; }
|
||||
public DateTime ProcessedAt { get; set; }
|
||||
public string? Description { get; set; }
|
||||
}
|
||||
|
||||
public record GetPayrollProcessListQuery(GetPayrollProcessListRequest Data) : IRequest<List<GetPayrollProcessListResponse>>;
|
||||
|
||||
public class GetPayrollProcessListHandler : IRequestHandler<GetPayrollProcessListQuery, List<GetPayrollProcessListResponse>>
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
|
||||
public GetPayrollProcessListHandler(AppDbContext context) => _context = context;
|
||||
|
||||
public async Task<List<GetPayrollProcessListResponse>> Handle(GetPayrollProcessListQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var data = await _context.PayrollProcess
|
||||
.OrderByDescending(x => x.FromDate)
|
||||
.Select(x => new GetPayrollProcessListResponse
|
||||
{
|
||||
Id = x.Id,
|
||||
AutoNumber = x.AutoNumber,
|
||||
PeriodName = x.PeriodName,
|
||||
FromDate = x.FromDate,
|
||||
ToDate = x.ToDate,
|
||||
TotalEmployees = x.TotalEmployees,
|
||||
TotalBasicSalary = x.TotalBasicSalary,
|
||||
TotalIncome = x.TotalIncome,
|
||||
TotalDeduction = x.TotalDeduction,
|
||||
TotalGross = x.TotalGross,
|
||||
TotalTakeHomePay = x.TotalTakeHomePay,
|
||||
Status = x.Status,
|
||||
ProcessedBy = x.ProcessedBy,
|
||||
ProcessedAt = x.ProcessedAt,
|
||||
Description = x.Description
|
||||
})
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user