From ff3e82e8975a3d1d13e5c18f82e30791b9ebd279 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Tue, 4 Aug 2026 18:24:35 +0330 Subject: [PATCH] #495 comment ratings --- GanjooRazor/Pages/GanjoorPage.cshtml.cs | 17 ++++++ GanjooRazor/Pages/Map.cshtml | 2 +- GanjooRazor/Pages/Misc/Photos.cshtml | 2 +- .../GanjoorPage/_CommentPartial.cshtml | 10 ++++ .../Pages/Recitations/AudioClip.cshtml | 2 +- .../Pages/Recitations/ReportRecitation.cshtml | 2 +- GanjooRazor/Pages/Shared/_AdminLayout.cshtml | 2 +- GanjooRazor/Pages/Shared/_Layout.cshtml | 2 +- .../Pages/Shared/_UserPanelLayout.cshtml | 2 +- GanjooRazor/wwwroot/js/bk.js | 53 +++++++++++++++++++ .../GanjoorService-CommentRating.cs | 5 ++ 11 files changed, 92 insertions(+), 7 deletions(-) diff --git a/GanjooRazor/Pages/GanjoorPage.cshtml.cs b/GanjooRazor/Pages/GanjoorPage.cshtml.cs index 385294be..018cfbb7 100644 --- a/GanjooRazor/Pages/GanjoorPage.cshtml.cs +++ b/GanjooRazor/Pages/GanjoorPage.cshtml.cs @@ -213,6 +213,23 @@ namespace GanjooRazor.Pages }); } + /// + /// like / dislike / clear rating for a comment (AJAX, called from rateComment() in bk.js) + /// + public Task OnPostRateCommentAsync(int id, short value) + { + return WithSecureClientAsync(async secureClient => + { + var response = await secureClient.PostAsync($"{APIRoot.Url}/api/ganjoor/poem/comment/{id}/rate?value={value}", null); + if (!response.IsSuccessStatusCode) + { + return new BadRequestObjectResult(await ReadErrorMessageAsync(response)); + } + var result = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); + return new JsonResult(result); + }); + } + /// /// Poets (for this page's own #hdr2 author dropdown - same pattern as Search/Simi/etc.) /// diff --git a/GanjooRazor/Pages/Map.cshtml b/GanjooRazor/Pages/Map.cshtml index bf4227ef..66dd1fc5 100644 --- a/GanjooRazor/Pages/Map.cshtml +++ b/GanjooRazor/Pages/Map.cshtml @@ -23,7 +23,7 @@ font-family: 'Vazirmatn' } - + diff --git a/GanjooRazor/Pages/Misc/Photos.cshtml b/GanjooRazor/Pages/Misc/Photos.cshtml index 7598abd9..56c69f1e 100644 --- a/GanjooRazor/Pages/Misc/Photos.cshtml +++ b/GanjooRazor/Pages/Misc/Photos.cshtml @@ -15,7 +15,7 @@ - + - + diff --git a/GanjooRazor/Pages/Recitations/ReportRecitation.cshtml b/GanjooRazor/Pages/Recitations/ReportRecitation.cshtml index fbb9143d..3fc51aca 100644 --- a/GanjooRazor/Pages/Recitations/ReportRecitation.cshtml +++ b/GanjooRazor/Pages/Recitations/ReportRecitation.cshtml @@ -238,7 +238,7 @@ - + diff --git a/GanjooRazor/Pages/Shared/_AdminLayout.cshtml b/GanjooRazor/Pages/Shared/_AdminLayout.cshtml index 63f751c3..c3c01f62 100644 --- a/GanjooRazor/Pages/Shared/_AdminLayout.cshtml +++ b/GanjooRazor/Pages/Shared/_AdminLayout.cshtml @@ -35,7 +35,7 @@ }); - + - + - +