initial commit
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
using Indotalent.ConfigBackEnd.Extensions;
|
||||
using Indotalent.Infrastructure.Database;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Indotalent.Features.Performance.Transfer.Cqrs;
|
||||
|
||||
public class LookupResponse
|
||||
{
|
||||
public string Id { get; set; } = string.Empty;
|
||||
public string Name { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public record GetBranchLookupQuery() : IRequest<List<LookupResponse>>;
|
||||
public record GetDepartmentLookupQuery() : IRequest<List<LookupResponse>>;
|
||||
public record GetDesignationLookupQuery() : IRequest<List<LookupResponse>>;
|
||||
|
||||
public class GetTransferLookupsHandler :
|
||||
IRequestHandler<GetBranchLookupQuery, List<LookupResponse>>,
|
||||
IRequestHandler<GetDepartmentLookupQuery, List<LookupResponse>>,
|
||||
IRequestHandler<GetDesignationLookupQuery, List<LookupResponse>>
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
public GetTransferLookupsHandler(AppDbContext context) => _context = context;
|
||||
|
||||
public async Task<List<LookupResponse>> Handle(GetBranchLookupQuery request, CancellationToken ct)
|
||||
{
|
||||
return await _context.Branch.AsNoTracking().NotDeletedOnly()
|
||||
.Select(x => new LookupResponse { Id = x.Id, Name = x.Name ?? "" }).ToListAsync(ct);
|
||||
}
|
||||
|
||||
public async Task<List<LookupResponse>> Handle(GetDepartmentLookupQuery request, CancellationToken ct)
|
||||
{
|
||||
return await _context.Department.AsNoTracking().NotDeletedOnly()
|
||||
.Select(x => new LookupResponse { Id = x.Id, Name = x.Name ?? "" }).ToListAsync(ct);
|
||||
}
|
||||
|
||||
public async Task<List<LookupResponse>> Handle(GetDesignationLookupQuery request, CancellationToken ct)
|
||||
{
|
||||
return await _context.Designation.AsNoTracking().NotDeletedOnly()
|
||||
.Select(x => new LookupResponse { Id = x.Id, Name = x.Name ?? "" }).ToListAsync(ct);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user