27 lines
694 B
C#
27 lines
694 B
C#
using Femto.Common.Domain;
|
|
using Femto.Modules.Auth.Application.Dto;
|
|
using Femto.Modules.Auth.Data;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Femto.Modules.Auth.Application.Interface.GetUserInfo;
|
|
|
|
internal class GetUserInfoCommandHandler(AuthContext context)
|
|
: ICommandHandler<GetUserInfoCommand, UserInfo?>
|
|
{
|
|
public async Task<UserInfo?> Handle(
|
|
GetUserInfoCommand request,
|
|
CancellationToken cancellationToken
|
|
)
|
|
{
|
|
|
|
var user = await context.Users.SingleOrDefaultAsync(
|
|
u => u.Id == request.ForUser,
|
|
cancellationToken
|
|
);
|
|
|
|
if (user is null)
|
|
return null;
|
|
|
|
return new UserInfo(user);
|
|
}
|
|
}
|