initial commit
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
using Indotalent.Infrastructure.Database;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Indotalent.Features.Payroll.Grade.Cqrs;
|
||||
|
||||
public class GetGradeListResponse
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public string? Code { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public decimal SalaryFrom { get; set; }
|
||||
public decimal SalaryTo { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public bool IsOverTimeEligible { get; set; }
|
||||
public string? Status { get; set; }
|
||||
public DateTimeOffset? CreatedAt { get; set; }
|
||||
}
|
||||
|
||||
public record GetGradeListQuery() : IRequest<List<GetGradeListResponse>>;
|
||||
|
||||
public class GetGradeListHandler : IRequestHandler<GetGradeListQuery, List<GetGradeListResponse>>
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
|
||||
public GetGradeListHandler(AppDbContext context) => _context = context;
|
||||
|
||||
public async Task<List<GetGradeListResponse>> Handle(GetGradeListQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
return await _context.Grade
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Code)
|
||||
.Select(x => new GetGradeListResponse
|
||||
{
|
||||
Id = x.Id,
|
||||
Code = x.Code,
|
||||
Name = x.Name,
|
||||
SalaryFrom = x.SalaryFrom,
|
||||
SalaryTo = x.SalaryTo,
|
||||
Description = x.Description,
|
||||
IsOverTimeEligible = x.IsOverTimeEligible,
|
||||
Status = x.Status,
|
||||
CreatedAt = x.CreatedAt
|
||||
})
|
||||
.ToListAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user