Adds CreatorAlias User responses
This commit is contained in:
@@ -1,12 +1,28 @@
|
||||
using FastEndpoints;
|
||||
using FluentValidation;
|
||||
using Hutopy.Application.Common.Interfaces;
|
||||
using Hutopy.Application.Common.Models;
|
||||
|
||||
namespace Hutopy.Web.Features.Creators.Handlers;
|
||||
|
||||
public sealed class GetCreatorByAliasRequest
|
||||
{
|
||||
public string CreatorAlias { get; set; }
|
||||
}
|
||||
|
||||
public sealed class GetCreatorByAliasRequestValidator
|
||||
: Validator<GetCreatorByAliasRequest>
|
||||
{
|
||||
public GetCreatorByAliasRequestValidator()
|
||||
{
|
||||
RuleFor(r => r.CreatorAlias)
|
||||
.NotNull().WithMessage("You must specify a creator-alias");
|
||||
}
|
||||
}
|
||||
|
||||
public class GetCreatorByAlias(
|
||||
IIdentityService identityService)
|
||||
: EndpointWithoutRequest<UserModel?>
|
||||
: Endpoint<GetCreatorByAliasRequest, UserModel?>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
@@ -16,13 +32,12 @@ public class GetCreatorByAlias(
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(
|
||||
GetCreatorByAliasRequest req,
|
||||
CancellationToken ct)
|
||||
{
|
||||
var creatorAlias = Route<string>("CreatorAlias");
|
||||
|
||||
ArgumentException.ThrowIfNullOrEmpty(creatorAlias);
|
||||
|
||||
var user = await identityService.FindUserByCreatorAliasAsync(creatorAlias, ct);
|
||||
var user = await identityService.FindUserByCreatorAliasAsync(
|
||||
req.CreatorAlias,
|
||||
ct);
|
||||
|
||||
await SendAsync(user, cancellation: ct);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user