From 3e1bfd31dfdc1bfec7806402d48867aacbf4dbb0 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Tue, 26 Nov 2024 10:05:19 +0330 Subject: [PATCH] delete cat bug fix --- RMuseum/Services/Implementation/GanjoorService.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/RMuseum/Services/Implementation/GanjoorService.cs b/RMuseum/Services/Implementation/GanjoorService.cs index 6a2afa69..cb66a3b1 100644 --- a/RMuseum/Services/Implementation/GanjoorService.cs +++ b/RMuseum/Services/Implementation/GanjoorService.cs @@ -3399,8 +3399,11 @@ namespace RMuseum.Services.Implementation var corrections = await _context.GanjoorPoemCorrections.Include(c => c.VerseOrderText).Where(c => c.PoemId == id).ToListAsync(); _context.RemoveRange(corrections); - var page = await _context.GanjoorPages.Where(p => p.Id == id && p.GanjoorPageType == GanjoorPageType.PoemPage).SingleAsync(); - _context.Remove(page); + var page = await _context.GanjoorPages.Where(p => p.Id == id && p.GanjoorPageType == GanjoorPageType.PoemPage).SingleOrDefaultAsync(); + if(page != null) + { + _context.Remove(page); + } _context.Remove(poem);