using Indotalent.ConfigBackEnd.Extensions; using Indotalent.Infrastructure.Database; using MediatR; using Microsoft.EntityFrameworkCore; namespace Indotalent.Features.Organization.Designation.Cqrs; public class GetDesignationListResponse { public string? Id { get; set; } public string? AutoNumber { get; set; } public string? Code { get; set; } public string? Name { get; set; } public string? Level { get; set; } public string? Description { get; set; } } public record GetDesignationListQuery() : IRequest>; public class GetDesignationListHandler : IRequestHandler> { private readonly AppDbContext _context; public GetDesignationListHandler(AppDbContext context) => _context = context; public async Task> Handle(GetDesignationListQuery request, CancellationToken cancellationToken) { return await _context.Designation .AsNoTracking() .NotDeletedOnly() .OrderBy(x => x.Code) .Select(x => new GetDesignationListResponse { Id = x.Id, AutoNumber = x.AutoNumber, Code = x.Code, Name = x.Name, Level = x.Level, Description = x.Description, }) .ToListAsync(cancellationToken); } }