Persist explicit PhotoID on photo upload

This commit is contained in:
Aaron Po
2026-08-30 04:13:51 -04:00
parent d1d089aa73
commit 2de91bd0be
4 changed files with 10 additions and 13 deletions

View File

@@ -9,8 +9,6 @@ using Features.Emails.DependencyInjection;
using Features.Emails.Services;
using Features.ImageUploads.Commands.UploadPhoto;
using Features.ImageUploads.DependencyInjection;
using Features.Users.Controllers;
using Features.Users.DependencyInjection;
using FluentValidation;
using FluentValidation.AspNetCore;
using Infrastructure.FileUpload;

View File

@@ -24,10 +24,6 @@
<Project Path="Infrastructure/Infrastructure.Jwt/Infrastructure.Jwt.csproj" />
<Project Path="Infrastructure/Infrastructure.PasswordHashing/Infrastructure.PasswordHashing.csproj" />
</Folder>
<Folder Name="/Infrastructure/Email/">
<Project Path="Infrastructure/Infrastructure.Email/Infrastructure.Email.csproj" />
<Project Path="Infrastructure/Infrastructure.Email.Templates/Infrastructure.Email.Templates.csproj" />
</Folder>
<Folder Name="/Features/" />
<Folder Name="/Features/Breweries/">
<Project Path="Features/Features.Breweries/Features.Breweries.csproj" />
@@ -40,8 +36,6 @@
<Folder Name="/Features/Locations/">
<Project Path="Features/Features.Locations/Features.Locations.csproj" />
<Project Path="Features/Features.Locations.Tests/Features.Locations.Tests.csproj" />
<Project Path="Features\Features.PhotoUpload\Features.PhotoUpload.csproj" />
<Project Path="Features/Features.PhotoUpload.Tests/Features.PhotoUpload.Tests.csproj" />
</Folder>
<Folder Name="/Features/PhotoUpload/">
<Project Path="Features/Features.PhotoUpload/Features.PhotoUpload.csproj" />

View File

@@ -25,7 +25,12 @@ public class UploadPhotoHandler(
cancellationToken
);
Photo photo = new() { Hyperlink = key, UploadedById = request.UploadedById };
Photo photo = new()
{
PhotoId = photoId,
Hyperlink = key,
UploadedById = request.UploadedById,
};
await photoUploadRepository.CreateAsync(photo, cancellationToken);

View File

@@ -44,10 +44,10 @@ public class PhotoUploadRepository(ISqlConnectionFactory connectionFactory)
await connection.ExecuteAsync(
new CommandDefinition(
"""
INSERT INTO dbo.Photo (Hyperlink, UploadedByID)
VALUES (@Hyperlink, @UploadedById)
INSERT INTO dbo.Photo (PhotoID, Hyperlink, UploadedByID)
VALUES (@PhotoId, @Hyperlink, @UploadedById)
""",
new { photo.Hyperlink, photo.UploadedById },
new { photo.PhotoId, photo.Hyperlink, photo.UploadedById },
transaction
)
);