From ebd52738dc02b76e78d5119341daf754d200c89e Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Thu, 7 Jul 2022 20:27:42 +0430 Subject: [PATCH] docs: #342 bring up user voted recitations for himself/herself --- GanjooRazor/Pages/Index.cshtml.cs | 8 ++++++-- GanjooRazor/Pages/RecitationsOrder.cshtml | 3 +++ .../ViewModels/PublicRecitationViewModel.cs | 5 +++++ RMuseum/RMuseum.xml | 5 +++++ .../Services/Implementation/GanjoorService.cs | 2 ++ .../Implementation/RecitationService.cs | 20 ++++++++++++++----- 6 files changed, 36 insertions(+), 7 deletions(-) diff --git a/GanjooRazor/Pages/Index.cshtml.cs b/GanjooRazor/Pages/Index.cshtml.cs index b0e8cc5a..e0b8fd00 100644 --- a/GanjooRazor/Pages/Index.cshtml.cs +++ b/GanjooRazor/Pages/Index.cshtml.cs @@ -371,9 +371,13 @@ namespace GanjooRazor.Pages if (response.IsSuccessStatusCode) { var upVotedIds = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); - foreach (var recitation in GanjoorPage.Poem.Recitations) + if(upVotedIds.Length > 0) { - recitation.UpVotedByUser = upVotedIds.Contains(recitation.Id); + foreach (var recitation in GanjoorPage.Poem.Recitations) + { + recitation.UpVotedByUser = upVotedIds.Contains(recitation.Id); + } + Array.Sort(GanjoorPage.Poem.Recitations, (a, b) => b.UpVotedByUser == a.UpVotedByUser ? a.AudioOrder.CompareTo(b.AudioOrder) : b.UpVotedByUser.CompareTo(a.UpVotedByUser)); } } diff --git a/GanjooRazor/Pages/RecitationsOrder.cshtml b/GanjooRazor/Pages/RecitationsOrder.cshtml index b2376f70..b8473559 100644 --- a/GanjooRazor/Pages/RecitationsOrder.cshtml +++ b/GanjooRazor/Pages/RecitationsOrder.cshtml @@ -81,6 +81,9 @@

* رأی ثبت شده توسط کاربر مالک خوانش در محاسبه لحاظ نمی‌شود.

+

+ * خوانش‌هایی که یک کاربر به آنها رأی داده (آنها را نشان کرده) در بازدید مجدد از شعر برای خود او فارغ از رتبه‌بندی گنجور بالاتر از بقیهٔ خوانش‌ها نمایش داده می‌شود. +

diff --git a/RMuseum/Models/GanjoorAudio/ViewModels/PublicRecitationViewModel.cs b/RMuseum/Models/GanjoorAudio/ViewModels/PublicRecitationViewModel.cs index ef8938c9..6bb02b5b 100644 --- a/RMuseum/Models/GanjoorAudio/ViewModels/PublicRecitationViewModel.cs +++ b/RMuseum/Models/GanjoorAudio/ViewModels/PublicRecitationViewModel.cs @@ -102,6 +102,11 @@ namespace RMuseum.Models.GanjoorAudio.ViewModels /// public RecitationMistakeViewModel[] Mistakes { get; set; } + /// + /// This determines where an audio is displayed between a list of sounds related to a specfic poem + /// + public int AudioOrder { get; set; } + /// /// upvoted by current user (filled at client) /// diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index 7277b270..7e8c3b1b 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -4861,6 +4861,11 @@ mistakes + + + This determines where an audio is displayed between a list of sounds related to a specfic poem + + upvoted by current user (filled at client) diff --git a/RMuseum/Services/Implementation/GanjoorService.cs b/RMuseum/Services/Implementation/GanjoorService.cs index 1ac7d43d..ce7cf266 100644 --- a/RMuseum/Services/Implementation/GanjoorService.cs +++ b/RMuseum/Services/Implementation/GanjoorService.cs @@ -643,6 +643,8 @@ namespace RMuseum.Services.Implementation XmlText = $"{WebServiceUrl.Url}/api/audio/xml/{audio.Id}", PlainText = "", //poem.PlainText HtmlText = "",//poem.HtmlText + AudioOrder = audio.AudioOrder, + UpVotedByUser = false, }; var recitations = await source.AsNoTracking().ToArrayAsync(); foreach (var recitation in recitations) diff --git a/RMuseum/Services/Implementation/RecitationService.cs b/RMuseum/Services/Implementation/RecitationService.cs index c25847fb..fd402017 100644 --- a/RMuseum/Services/Implementation/RecitationService.cs +++ b/RMuseum/Services/Implementation/RecitationService.cs @@ -149,7 +149,9 @@ namespace RMuseum.Services.Implementationa Mp3Url = $"{WebServiceUrl.Url}/api/audio/file/{audio.Id}.mp3", XmlText = $"{WebServiceUrl.Url}/api/audio/xml/{audio.Id}", PlainText = poem.PlainText, - HtmlText = poem.HtmlText + HtmlText = poem.HtmlText, + AudioOrder = audio.AudioOrder, + UpVotedByUser = false, }; (PaginationMetadata PagingMeta, PublicRecitationViewModel[] Items) paginatedResult = @@ -204,7 +206,9 @@ namespace RMuseum.Services.Implementationa Mp3Url = $"{WebServiceUrl.Url}/api/audio/file/{audio.Id}.mp3", XmlText = $"{WebServiceUrl.Url}/api/audio/xml/{audio.Id}", PlainText = poem.PlainText, - HtmlText = poem.HtmlText + HtmlText = poem.HtmlText, + AudioOrder = audio.AudioOrder, + UpVotedByUser = false, }; (PaginationMetadata PagingMeta, PublicRecitationViewModel[] Items) paginatedResult = @@ -258,7 +262,9 @@ namespace RMuseum.Services.Implementationa Mp3Url = $"{WebServiceUrl.Url}/api/audio/file/{audio.Id}.mp3", XmlText = $"{WebServiceUrl.Url}/api/audio/xml/{audio.Id}", PlainText = poem.PlainText, - HtmlText = poem.HtmlText + HtmlText = poem.HtmlText, + AudioOrder = audio.AudioOrder, + UpVotedByUser = false, }; (PaginationMetadata PagingMeta, PublicRecitationViewModel[] Items) paginatedResult = @@ -300,7 +306,9 @@ namespace RMuseum.Services.Implementationa Mp3Url = $"{WebServiceUrl.Url}/api/audio/file/{audio.Id}.mp3", XmlText = $"{WebServiceUrl.Url}/api/audio/xml/{audio.Id}", PlainText = poem.PlainText, - HtmlText = poem.HtmlText + HtmlText = poem.HtmlText, + AudioOrder = audio.AudioOrder, + UpVotedByUser = false, }; return new RServiceResult(await source.SingleOrDefaultAsync()); @@ -2172,7 +2180,9 @@ namespace RMuseum.Services.Implementationa Mp3Url = $"{WebServiceUrl.Url}/api/audio/file/{upvote.Recitation.Id}.mp3", XmlText = $"{WebServiceUrl.Url}/api/audio/xml/{upvote.Recitation.Id}", PlainText = poem.PlainText, - HtmlText = poem.HtmlText + HtmlText = poem.HtmlText, + AudioOrder = upvote.Recitation.AudioOrder, + UpVotedByUser = true, }; (PaginationMetadata PagingMeta, PublicRecitationViewModel[] Items) paginatedResult =