From 89a4140b53a4130a716dfa4ff88b0d337081d9ff Mon Sep 17 00:00:00 2001 From: eee4 <41441600+eee4@users.noreply.github.com> Date: Thu, 24 Jul 2025 13:20:15 +0200 Subject: [PATCH] fix: remove references to deleted images from quotes --- Controllers/UserContentController.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Controllers/UserContentController.cs b/Controllers/UserContentController.cs index 94804b8..5be142c 100644 --- a/Controllers/UserContentController.cs +++ b/Controllers/UserContentController.cs @@ -189,6 +189,18 @@ public class UserContentController : ControllerBase } // - from db + // - first, from any quotes that reference it + List quotesToModify = await _db.Quotes + .Include(q => q.Image) + .Where(q => q.Image == image) + .ToListAsync(); + + foreach (Quote quote in quotesToModify) + { + quote.Image = null; + } + + // - finally, from images table _db.Images.Remove(image); await _db.SaveChangesAsync();