From 7293fdd6d38fec50e689b7a506317e09023fc961 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Thu, 7 Apr 2022 10:41:02 +0430 Subject: [PATCH] docs: #306 adding poem sections to GanjoorPoemCompleteViewModel --- RMuseum/Models/Ganjoor/GanjoorPoemSection.cs | 34 -------- RMuseum/Models/Ganjoor/PoemSectionType.cs | 25 ++++++ .../Models/Ganjoor/VersePoemSectionType.cs | 12 +++ .../GanjoorPoemCompleteViewModel.cs | 5 ++ RMuseum/RMuseum.xml | 85 ++++++++++++------- RMuseum/Services/IGanjoorService.cs | 10 ++- .../Services/Implementation/GanjoorService.cs | 29 ++++++- 7 files changed, 131 insertions(+), 69 deletions(-) create mode 100644 RMuseum/Models/Ganjoor/PoemSectionType.cs create mode 100644 RMuseum/Models/Ganjoor/VersePoemSectionType.cs diff --git a/RMuseum/Models/Ganjoor/GanjoorPoemSection.cs b/RMuseum/Models/Ganjoor/GanjoorPoemSection.cs index 2e8d8a34..2f0b5ec6 100644 --- a/RMuseum/Models/Ganjoor/GanjoorPoemSection.cs +++ b/RMuseum/Models/Ganjoor/GanjoorPoemSection.cs @@ -1,39 +1,5 @@ namespace RMuseum.Models.Ganjoor { - - /// - /// poem section type - /// - public enum PoemSectionType - { - /// - /// sections like paragraphs or poems within paragraphs of text - /// - WholePoem = 0, - /// - /// bands of a multi-band poem - /// - Band = 1, - /// - /// band couplets (virtual) some are virtual because they contain verse from different parts of poems (like verses from all band couplets) - /// - BandCouplets = 2, - /// - /// couplets (virtual) for Masnavi - /// - Couplet = 3, - } - - /// - /// how GanjoorPoemSection is linked to GanjoorVerse - /// - public enum VersePoemSectionType - { - First = 1, - Second = 2, - Third = 3, - } - /// /// Ganjoor Poem Section /// diff --git a/RMuseum/Models/Ganjoor/PoemSectionType.cs b/RMuseum/Models/Ganjoor/PoemSectionType.cs new file mode 100644 index 00000000..adad2cde --- /dev/null +++ b/RMuseum/Models/Ganjoor/PoemSectionType.cs @@ -0,0 +1,25 @@ +namespace RMuseum.Models.Ganjoor +{ + /// + /// poem section type + /// + public enum PoemSectionType + { + /// + /// sections like paragraphs or poems within paragraphs of text + /// + WholePoem = 0, + /// + /// bands of a multi-band poem + /// + Band = 1, + /// + /// band couplets (virtual) some are virtual because they contain verse from different parts of poems (like verses from all band couplets) + /// + BandCouplets = 2, + /// + /// couplets (virtual) for Masnavi + /// + Couplet = 3, + } +} diff --git a/RMuseum/Models/Ganjoor/VersePoemSectionType.cs b/RMuseum/Models/Ganjoor/VersePoemSectionType.cs new file mode 100644 index 00000000..0590c075 --- /dev/null +++ b/RMuseum/Models/Ganjoor/VersePoemSectionType.cs @@ -0,0 +1,12 @@ +namespace RMuseum.Models.Ganjoor +{ + /// + /// how GanjoorPoemSection is linked to GanjoorVerse + /// + public enum VersePoemSectionType + { + First = 1, + Second = 2, + Third = 3, + } +} diff --git a/RMuseum/Models/Ganjoor/ViewModels/GanjoorPoemCompleteViewModel.cs b/RMuseum/Models/Ganjoor/ViewModels/GanjoorPoemCompleteViewModel.cs index bf13171e..ebb7b0d4 100644 --- a/RMuseum/Models/Ganjoor/ViewModels/GanjoorPoemCompleteViewModel.cs +++ b/RMuseum/Models/Ganjoor/ViewModels/GanjoorPoemCompleteViewModel.cs @@ -131,5 +131,10 @@ namespace RMuseum.Models.Ganjoor.ViewModels /// top 6 related poems /// public GanjoorCachedRelatedPoem[] Top6RelatedPoems { get; set; } + + /// + /// poem sections + /// + public GanjoorPoemSection[] Sections { get; set; } } } diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index 14204242..d8a1b9e5 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -6746,36 +6746,6 @@ metre - - - poem section type - - - - - sections like paragraphs or poems within paragraphs of text - - - - - bands of a multi-band poem - - - - - band couplets (virtual) some are virtual because they contain verse from different parts of poems (like verses from all band couplets) - - - - - couplets (virtual) for Masnavi - - - - - how GanjoorPoemSection is linked to GanjoorVerse - - Ganjoor Poem Section @@ -7554,6 +7524,36 @@ https://open.spotify.com/ + + + poem section type + + + + + sections like paragraphs or poems within paragraphs of text + + + + + bands of a multi-band poem + + + + + band couplets (virtual) some are virtual because they contain verse from different parts of poems (like verses from all band couplets) + + + + + couplets (virtual) for Masnavi + + + + + how GanjoorPoemSection is linked to GanjoorVerse + + معنی فیلد position در جدول verse با توجه به مقادیر این ساختار داده مشخص می شود. @@ -8376,6 +8376,11 @@ top 6 related poems + + + poem sections + + poem correction view model @@ -10833,7 +10838,7 @@ - + Get Poem By Id @@ -10848,6 +10853,7 @@ + @@ -10873,6 +10879,13 @@ + + + get poem sections + + + + get user up votes for the recitations of a poem @@ -13542,6 +13555,13 @@ + + + get poem sections + + + + get user up votes for the recitations of a poem @@ -13674,7 +13694,7 @@ - + Get Poem By Id @@ -13689,6 +13709,7 @@ + sections diff --git a/RMuseum/Services/IGanjoorService.cs b/RMuseum/Services/IGanjoorService.cs index d8711d13..f1cdcb48 100644 --- a/RMuseum/Services/IGanjoorService.cs +++ b/RMuseum/Services/IGanjoorService.cs @@ -110,8 +110,9 @@ namespace RMuseum.Services /// /// /// + /// /// - Task> GetPoemById(int id, bool catInfo = true, bool catPoems = false, bool rhymes = true, bool recitations = true, bool images = true, bool songs = true, bool comments = true, bool verseDetails = true, bool navigation = true, bool relatedpoems = true); + Task> GetPoemById(int id, bool catInfo = true, bool catPoems = false, bool rhymes = true, bool recitations = true, bool images = true, bool songs = true, bool comments = true, bool verseDetails = true, bool navigation = true, bool relatedpoems = true, bool sections = true); /// /// Get Poem By Url @@ -136,6 +137,13 @@ namespace RMuseum.Services /// Task> GetPoemRecitations(int id); + /// + /// get poem sections + /// + /// + /// + Task> GetPoemSections(int id); + /// /// get user up votes for the recitations of a poem /// diff --git a/RMuseum/Services/Implementation/GanjoorService.cs b/RMuseum/Services/Implementation/GanjoorService.cs index 435bd534..6a78279d 100644 --- a/RMuseum/Services/Implementation/GanjoorService.cs +++ b/RMuseum/Services/Implementation/GanjoorService.cs @@ -633,6 +633,20 @@ namespace RMuseum.Services.Implementation return new RServiceResult(recitations); } + + /// + /// get poem sections + /// + /// + /// + public async Task> GetPoemSections(int id) + { + return new RServiceResult( + await _context.GanjoorPoemSections.AsNoTracking().Where(s => s.PoemId == id).ToArrayAsync() + ); + } + + /// /// get user up votes for the recitations of a poem /// @@ -1452,8 +1466,9 @@ namespace RMuseum.Services.Implementation /// /// /// + /// sections /// - public async Task> GetPoemById(int id, bool catInfo = true, bool catPoems = false, bool rhymes = true, bool recitations = true, bool images = true, bool songs = true, bool comments = true, bool verseDetails = true, bool navigation = true, bool relatedpoems = true) + public async Task> GetPoemById(int id, bool catInfo = true, bool catPoems = false, bool rhymes = true, bool recitations = true, bool images = true, bool songs = true, bool comments = true, bool verseDetails = true, bool navigation = true, bool relatedpoems = true, bool sections = true) { var cachKey = $"GetPoemById({id}, {catInfo}, {catPoems}, {rhymes}, {recitations}, {images}, {songs}, {comments}, {verseDetails}, {navigation})"; if (!_memoryCache.TryGetValue(cachKey, out GanjoorPoemCompleteViewModel poemViewModel)) @@ -1600,6 +1615,15 @@ namespace RMuseum.Services.Implementation top6relatedPoems = relatedPoemsRes.Result; } + GanjoorPoemSection[] poemSections = null; + if(sections) + { + var poemSectionsRes = await GetPoemSections(id); + if (!string.IsNullOrEmpty(poemSectionsRes.ExceptionString)) + return new RServiceResult(null, poemSectionsRes.ExceptionString); + poemSections = poemSectionsRes.Result; + } + poemViewModel = new GanjoorPoemCompleteViewModel() { @@ -1627,7 +1651,8 @@ namespace RMuseum.Services.Implementation Verses = verses, Songs = tracks, Comments = poemComments, - Top6RelatedPoems = top6relatedPoems + Top6RelatedPoems = top6relatedPoems, + Sections = poemSections }; if (AggressiveCacheEnabled)