using Indotalent.Infrastructure.Database; using MediatR; using Microsoft.EntityFrameworkCore; namespace Indotalent.Features.Payroll.Income.Cqrs; public class GetIncomeListResponse { public string? Id { get; set; } public string? Code { get; set; } public string? Name { get; set; } public string? Type { get; set; } public bool IsTaxable { get; set; } public string? CalculationBase { get; set; } public string? Status { get; set; } public DateTimeOffset? CreatedAt { get; set; } } public record GetIncomeListQuery() : IRequest>; public class GetIncomeListHandler : IRequestHandler> { private readonly AppDbContext _context; public GetIncomeListHandler(AppDbContext context) => _context = context; public async Task> Handle(GetIncomeListQuery request, CancellationToken cancellationToken) { return await _context.Income .AsNoTracking() .OrderBy(x => x.Code) .Select(x => new GetIncomeListResponse { Id = x.Id, Code = x.Code, Name = x.Name, Type = x.Type, IsTaxable = x.IsTaxable, CalculationBase = x.CalculationBase, Status = x.Status, CreatedAt = x.CreatedAt }) .ToListAsync(cancellationToken); } }