1
This commit is contained in:
36
Yes.Application/Admins/Users/GetUsersQueryHandler.cs
Normal file
36
Yes.Application/Admins/Users/GetUsersQueryHandler.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
namespace Yes.Application.Admins.Users
|
||||
{
|
||||
|
||||
public record GetUsersQuery() : IRequest<List<GetUsersQueryResponse>>;
|
||||
|
||||
public record GetUsersQueryResponse(
|
||||
int Id,
|
||||
string Name,
|
||||
string Email,
|
||||
string NickName,
|
||||
DateTime? RegDate,
|
||||
bool IsSystem
|
||||
);
|
||||
|
||||
public class GetUsersQueryHandler(BlogDbContext db) : IRequestHandler<GetUsersQuery, List<GetUsersQueryResponse>>
|
||||
{
|
||||
private readonly BlogDbContext _db = db;
|
||||
public async Task<List<GetUsersQueryResponse>> Handle(GetUsersQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
var articles = await _db.Users.Select(x =>
|
||||
new GetUsersQueryResponse
|
||||
(
|
||||
x.Id,
|
||||
x.Name,
|
||||
x.Email,
|
||||
x.NickName,
|
||||
x.RegDate,
|
||||
x.IsSystem
|
||||
)
|
||||
).ToListAsync(cancellationToken);
|
||||
|
||||
return articles;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user