From 2de91bd0be64917aeaf4b5600f3a30337d1e657a Mon Sep 17 00:00:00 2001 From: Aaron Po Date: Sun, 30 Aug 2026 04:13:51 -0400 Subject: [PATCH] Persist explicit PhotoID on photo upload --- web/backend/API/API.Core/Program.cs | 2 -- web/backend/Biergarten.API.slnx | 8 +------- .../Commands/UploadPhoto/UploadPhotoHandler.cs | 7 ++++++- .../Repository/PhotoUploadRepository.cs | 6 +++--- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/web/backend/API/API.Core/Program.cs b/web/backend/API/API.Core/Program.cs index 68bb24af..daa28849 100644 --- a/web/backend/API/API.Core/Program.cs +++ b/web/backend/API/API.Core/Program.cs @@ -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; diff --git a/web/backend/Biergarten.API.slnx b/web/backend/Biergarten.API.slnx index a7cce055..b339fc59 100644 --- a/web/backend/Biergarten.API.slnx +++ b/web/backend/Biergarten.API.slnx @@ -24,10 +24,6 @@ - - - - @@ -40,8 +36,6 @@ - - @@ -51,4 +45,4 @@ - \ No newline at end of file + diff --git a/web/backend/Features/Features.PhotoUpload/Commands/UploadPhoto/UploadPhotoHandler.cs b/web/backend/Features/Features.PhotoUpload/Commands/UploadPhoto/UploadPhotoHandler.cs index 959a85fe..d857f2cd 100644 --- a/web/backend/Features/Features.PhotoUpload/Commands/UploadPhoto/UploadPhotoHandler.cs +++ b/web/backend/Features/Features.PhotoUpload/Commands/UploadPhoto/UploadPhotoHandler.cs @@ -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); diff --git a/web/backend/Features/Features.PhotoUpload/Repository/PhotoUploadRepository.cs b/web/backend/Features/Features.PhotoUpload/Repository/PhotoUploadRepository.cs index 76a0d475..49d40a55 100644 --- a/web/backend/Features/Features.PhotoUpload/Repository/PhotoUploadRepository.cs +++ b/web/backend/Features/Features.PhotoUpload/Repository/PhotoUploadRepository.cs @@ -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 ) );