Adds ChangePortrait for User

This commit is contained in:
2024-09-04 13:52:47 -04:00
parent f12418bc79
commit 3e341e0019
5 changed files with 103 additions and 48 deletions

View File

@@ -9,11 +9,15 @@ public record ChangeBannerRequest(
Guid CreatorId,
IFormFile File);
[PublicAPI]
public record ChangeBannerResponse(
string BlobUrl);
[PublicAPI]
public class ChangeBannerHandler(
ContentDbContext context,
IBlobStorage blobStorage)
: Endpoint<ChangeBannerRequest>
: Endpoint<ChangeBannerRequest, ChangeBannerResponse>
{
public override void Configure()
{
@@ -22,7 +26,9 @@ public class ChangeBannerHandler(
AllowFileUploads();
}
public override async Task HandleAsync(ChangeBannerRequest request, CancellationToken ct)
public override async Task HandleAsync(
ChangeBannerRequest request,
CancellationToken ct)
{
var creator = await context
.Creators
@@ -49,6 +55,8 @@ public class ChangeBannerHandler(
await context.SaveChangesAsync(ct);
await SendOkAsync(blobUrl, ct);
await SendOkAsync(
new ChangeBannerResponse(blobUrl),
ct);
}
}

View File

@@ -9,6 +9,21 @@ public record ChangeLogoRequest(
Guid CreatorId,
IFormFile File);
[PublicAPI]
public sealed class ChangeLogoRequestValidator : Validator<ChangeLogoRequest>
{
public ChangeLogoRequestValidator()
{
RuleFor(x => x.CreatorId)
.NotNull()
.NotEmpty();
RuleFor(x => x.File)
.NotNull()
.NotEmpty();
}
}
[PublicAPI]
public class ChangeLogoHandler(
ContentDbContext context,
@@ -22,7 +37,9 @@ public class ChangeLogoHandler(
AllowFileUploads();
}
public override async Task HandleAsync(ChangeLogoRequest request, CancellationToken ct)
public override async Task HandleAsync(
ChangeLogoRequest request,
CancellationToken ct)
{
var creator = await context
.Creators