using Indotalent.Infrastructure.Database; using MediatR; using Microsoft.EntityFrameworkCore; namespace Indotalent.Features.Leave.LeaveRequest.Cqrs; public class EmployeeLeaveReferenceResponse { public string? Id { get; set; } public string? Code { get; set; } public string? FullName { get; set; } } public record GetEmployeeLeaveReferenceQuery() : IRequest>; public class GetEmployeeLeaveReferenceHandler : IRequestHandler> { private readonly AppDbContext _context; public GetEmployeeLeaveReferenceHandler(AppDbContext context) => _context = context; public async Task> Handle(GetEmployeeLeaveReferenceQuery request, CancellationToken cancellationToken) { return await _context.Employee .AsNoTracking() .Where(x => x.EmployeeStatus == "Active") .Select(x => new EmployeeLeaveReferenceResponse { Id = x.Id, Code = x.Code, FullName = $"{x.FirstName} {x.LastName}" }) .ToListAsync(cancellationToken); } }