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.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<List<GetDesignationListResponse>>;
|
||||
|
||||
public class GetDesignationListHandler : IRequestHandler<GetDesignationListQuery, List<GetDesignationListResponse>>
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
|
||||
public GetDesignationListHandler(AppDbContext context) => _context = context;
|
||||
|
||||
public async Task<List<GetDesignationListResponse>> 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user