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();