From afa5b24ded45502cbc499b6f3b680e1d12efabf4 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Fri, 25 Sep 2026 12:54:51 +0330 Subject: [PATCH] geotag edit fix --- GanjooRazor/Areas/User/Pages/Editor.cshtml.cs | 16 +++++++++++++++- .../Services/Implementation/GanjoorService.cs | 3 ++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/GanjooRazor/Areas/User/Pages/Editor.cshtml.cs b/GanjooRazor/Areas/User/Pages/Editor.cshtml.cs index 1babec08..07d4c576 100644 --- a/GanjooRazor/Areas/User/Pages/Editor.cshtml.cs +++ b/GanjooRazor/Areas/User/Pages/Editor.cshtml.cs @@ -363,7 +363,21 @@ namespace GanjooRazor.Areas.User.Pages $"{APIRoot.Url}/api/ganjoor/poem/correction/{poemid}"); if (!response.IsSuccessStatusCode) { - return BadRequest(JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync())); + string rawError = await response.Content.ReadAsStringAsync(); + string errorMessage; + try + { + // normal case: API returns the error as a JSON-encoded string + errorMessage = JsonConvert.DeserializeObject(rawError); + } + catch (JsonException) + { + // API (or a proxy in front of it) returned something that isn't a + // JSON string - e.g. an HTML error page - so don't let that throw + // an unhandled exception here; fall back to a generic message. + errorMessage = "خطایی در سرور رخ داد. لطفاً بعداً دوباره تلاش کنید."; + } + return BadRequest(errorMessage); } return new OkObjectResult(true); } diff --git a/RMuseum/Services/Implementation/GanjoorService.cs b/RMuseum/Services/Implementation/GanjoorService.cs index cddcef9d..9c7b7ab7 100644 --- a/RMuseum/Services/Implementation/GanjoorService.cs +++ b/RMuseum/Services/Implementation/GanjoorService.cs @@ -2043,7 +2043,7 @@ namespace RMuseum.Services.Implementation /// public async Task> DeletePoemCorrections(Guid userId, int poemId) { - var preCorrections = await _context.GanjoorPoemCorrections.Include(c => c.VerseOrderText) + var preCorrections = await _context.GanjoorPoemCorrections.Include(c => c.VerseOrderText).Include(c => c.GeoDateTags) .Where(c => c.UserId == userId && c.PoemId == poemId && c.Reviewed == false) .ToListAsync(); if (preCorrections.Count > 0) @@ -2051,6 +2051,7 @@ namespace RMuseum.Services.Implementation foreach (var preCorrection in preCorrections) { preCorrection.VerseOrderText.Clear(); + preCorrection.GeoDateTags?.Clear(); } _context.GanjoorPoemCorrections.RemoveRange(preCorrections); await _context.SaveChangesAsync();