using Indotalent.Infrastructure.Database; using MediatR; using Microsoft.EntityFrameworkCore; namespace Indotalent.Features.Utilities.ProgramResource.Cqrs; public class GetProgramResourceListResponse { public string? Id { get; set; } public string? Name { get; set; } public string? Description { get; set; } } public record GetProgramResourceListQuery() : IRequest>; public class GetProgramResourceListHandler : IRequestHandler> { private readonly AppDbContext _context; public GetProgramResourceListHandler(AppDbContext context) => _context = context; public async Task> Handle(GetProgramResourceListQuery request, CancellationToken cancellationToken) { return await _context.ProgramManagerResource .AsNoTracking() .OrderBy(x => x.Name) .Select(x => new GetProgramResourceListResponse { Id = x.Id, Name = x.Name, Description = x.Description }) .ToListAsync(cancellationToken); } }