Transit
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using Hutopy.Web.Features.Contents.Data;
|
||||
using Hutopy.Web.Features.Contents.Handlers.Models;
|
||||
|
||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||
|
||||
@@ -10,18 +9,31 @@ public sealed class GetCreatorByAliasRequest
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public record struct GetCreatorByAliasResponse(
|
||||
Guid Id,
|
||||
Guid CreatedBy,
|
||||
DateTimeOffset CreatedAt,
|
||||
bool Verified,
|
||||
bool AcceptDonation,
|
||||
string Name,
|
||||
string? Title,
|
||||
Socials Socials,
|
||||
Colors Colors,
|
||||
PresentationInfos PresentationInfos,
|
||||
Images Images);
|
||||
public class GetCreatorByAliasResponse(
|
||||
Guid id,
|
||||
Guid createdBy,
|
||||
DateTimeOffset createdAt,
|
||||
bool verified,
|
||||
bool acceptDonation,
|
||||
string name,
|
||||
string? title,
|
||||
Socials socials,
|
||||
Colors colors,
|
||||
PresentationInfos presentationInfos,
|
||||
Images images)
|
||||
{
|
||||
public Guid Id { get; } = id;
|
||||
public Guid CreatedBy { get; } = createdBy;
|
||||
public DateTimeOffset CreatedAt { get; } = createdAt;
|
||||
public bool Verified { get; } = verified;
|
||||
public bool AcceptDonation { get; } = acceptDonation;
|
||||
public string Name { get; } = name;
|
||||
public string? Title { get; } = title;
|
||||
public Socials Socials { get; } = socials;
|
||||
public Colors Colors { get; } = colors;
|
||||
public PresentationInfos PresentationInfos { get; } = presentationInfos;
|
||||
public Images Images { get; } = images;
|
||||
}
|
||||
|
||||
[UsedImplicitly]
|
||||
public sealed class GetCreatorByAliasRequestValidator
|
||||
@@ -55,8 +67,22 @@ public class GetCreatorByAliasHandler(
|
||||
|
||||
var creator = await context
|
||||
.Creators
|
||||
.Where(c => EF.Functions.ILike(c.Name, creatorName))
|
||||
.FirstOrDefaultAsync(ct);
|
||||
.Where(c => EF.Functions.ILike(c.Slugs.Name, creatorName))
|
||||
.AsNoTracking()
|
||||
.Select(c => new GetCreatorByAliasResponse
|
||||
(
|
||||
c.Id,
|
||||
c.CreatedBy,
|
||||
c.CreatedAt,
|
||||
c.Verified,
|
||||
c.AcceptDonation,
|
||||
c.Slugs.NormalizedName,
|
||||
c.Title,
|
||||
c.Socials,
|
||||
c.Colors,
|
||||
c.PresentationInfos,
|
||||
c.Images))
|
||||
.SingleOrDefaultAsync(ct);
|
||||
|
||||
if (creator is null)
|
||||
{
|
||||
@@ -64,20 +90,7 @@ public class GetCreatorByAliasHandler(
|
||||
}
|
||||
else
|
||||
{
|
||||
var model = new GetCreatorByAliasResponse(
|
||||
creator.Id,
|
||||
creator.CreatedBy,
|
||||
creator.CreatedAt,
|
||||
creator.Verified,
|
||||
creator.AcceptDonation,
|
||||
creator.Name,
|
||||
creator.Title,
|
||||
creator.Socials,
|
||||
creator.Colors,
|
||||
creator.PresentationInfos,
|
||||
creator.Images);
|
||||
|
||||
await SendAsync(model, cancellation: ct);
|
||||
await SendAsync(creator, cancellation: ct);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user