initial commit
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
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<List<GetProgramResourceListResponse>>;
|
||||
|
||||
public class GetProgramResourceListHandler : IRequestHandler<GetProgramResourceListQuery, List<GetProgramResourceListResponse>>
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
|
||||
public GetProgramResourceListHandler(AppDbContext context) => _context = context;
|
||||
|
||||
public async Task<List<GetProgramResourceListResponse>> 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user