Ajout de PublicCreatorInfo
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
namespace Hutopy.Application.Users.Queries.GetCreatorInfo;
|
||||
|
||||
public class CreatorInfoDto
|
||||
{
|
||||
public required string FirstName { get; init; }
|
||||
public required string LastName { get; init; }
|
||||
public string UserName { get; init; } = String.Empty;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using Hutopy.Application.Common.Interfaces;
|
||||
|
||||
namespace Hutopy.Application.Users.Queries.GetCreatorInfo;
|
||||
|
||||
public record GetCreatorInfoQuery : IRequest<CreatorInfoDto>
|
||||
{
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
};
|
||||
|
||||
|
||||
public class GetCreatorInfoHandler(
|
||||
IIdentityService identityService
|
||||
)
|
||||
: IRequestHandler<GetCreatorInfoQuery, CreatorInfoDto>
|
||||
{
|
||||
public async Task<CreatorInfoDto> Handle(GetCreatorInfoQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
var userName = await identityService.GetUserByUserNameAsync(request.UserName);
|
||||
var creatorInfo = new CreatorInfoDto
|
||||
{
|
||||
|
||||
FirstName = userName?.FirstName ?? "",
|
||||
LastName = userName?.LastName ?? "",
|
||||
UserName = userName?.UserName ?? "",
|
||||
|
||||
};
|
||||
return creatorInfo;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user