diff --git a/GanjooRazor/Pages/Index.cshtml b/GanjooRazor/Pages/Index.cshtml index 6e99bd50..47537c24 100644 --- a/GanjooRazor/Pages/Index.cshtml +++ b/GanjooRazor/Pages/Index.cshtml @@ -204,9 +204,6 @@ - - - @if (!string.IsNullOrEmpty(ViewData["GoogleAnalyticsCode"].ToString())) { } + @if(Model.LoggedIn && Model.IsPoemPage) + { + if(Model.GanjoorPage.Poem.Recitations.Length > 0) + { + + } + } + diff --git a/GanjooRazor/Pages/Index.cshtml.cs b/GanjooRazor/Pages/Index.cshtml.cs index 75936db3..1ab483a7 100644 --- a/GanjooRazor/Pages/Index.cshtml.cs +++ b/GanjooRazor/Pages/Index.cshtml.cs @@ -837,6 +837,24 @@ namespace GanjooRazor.Pages return new OkObjectResult(false); } + public async Task OnGetGetUserUpvotedRecitationsAsync(int poemId) + { + using (HttpClient secureClient = new HttpClient()) + { + if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) + { + HttpResponseMessage response = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/poem/{poemId}/recitations/upvotes"); + if (!response.IsSuccessStatusCode) + { + return new BadRequestObjectResult(JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync())); + } + var res = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); + return new OkObjectResult(res); + } + } + return new OkObjectResult("کاربر وارد سیستم نشده است یا مشکل دیگری دارد."); + } + public async Task OnPostSwitchRecitationUpVoteAsync(int id) { using (HttpClient secureClient = new HttpClient()) diff --git a/GanjooRazor/wwwroot/js/bk.js b/GanjooRazor/wwwroot/js/bk.js index d34b466c..3bb4d3e8 100644 --- a/GanjooRazor/wwwroot/js/bk.js +++ b/GanjooRazor/wwwroot/js/bk.js @@ -862,4 +862,23 @@ function switchRecitationVote(recitationId) { alert(e.responseText); }, }); -} \ No newline at end of file +} + +function MarkUserUpvotedRecitations(poemId) { + setTimeout(function () { + $.ajax({ + type: "GET", + url: '?Handler=GetUserUpvotedRecitations&poemId=' + String(poemId), + error: function (err) { + console.log(err); + }, + success: function (result) { + for (var i = 0; i < result.length; i++) { + if (result[i].upVote) { + document.getElementById('recitaion-' + String(result[i].id)).classList.add('recitation-vote'); + } + } + }, + }); + }, 1); +}