From de9cb0b07cef408fbfad429ea0c6cbdee2051f99 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Thu, 14 Apr 2022 12:29:01 +0430 Subject: [PATCH] docs: #306 adding related sections to poem sections --- RMuseum/Models/Ganjoor/GanjoorPoemSection.cs | 10 +++++++++- RMuseum/RMuseum.xml | 5 +++++ RMuseum/Services/Implementation/GanjoorService.cs | 12 +++++++++--- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/RMuseum/Models/Ganjoor/GanjoorPoemSection.cs b/RMuseum/Models/Ganjoor/GanjoorPoemSection.cs index ca99141d..c53ccbff 100644 --- a/RMuseum/Models/Ganjoor/GanjoorPoemSection.cs +++ b/RMuseum/Models/Ganjoor/GanjoorPoemSection.cs @@ -1,4 +1,6 @@ -namespace RMuseum.Models.Ganjoor +using System.ComponentModel.DataAnnotations.Schema; + +namespace RMuseum.Models.Ganjoor { /// /// Ganjoor Poem Section @@ -77,5 +79,11 @@ /// verses text as html (ganjoor.net format) /// public string HtmlText { get; set; } + + /// + /// top 6 related sections + /// + [NotMapped] + public GanjoorCachedRelatedSection[] Top6RelatedSections { get; set; } } } diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index d9d9bbd5..1caef731 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -6899,6 +6899,11 @@ verses text as html (ganjoor.net format) + + + top 6 related sections + + poem translation diff --git a/RMuseum/Services/Implementation/GanjoorService.cs b/RMuseum/Services/Implementation/GanjoorService.cs index 95607b04..7bbb4f19 100644 --- a/RMuseum/Services/Implementation/GanjoorService.cs +++ b/RMuseum/Services/Implementation/GanjoorService.cs @@ -645,9 +645,15 @@ namespace RMuseum.Services.Implementation /// public async Task> GetPoemWholeSections(int id) { - return new RServiceResult( - await _context.GanjoorPoemSections.AsNoTracking().Include(s => s.GanjoorMetre).Where(s => s.PoemId == id && s.SectionType == PoemSectionType.WholePoem).ToArrayAsync() - ); + var sections = + await _context.GanjoorPoemSections.AsNoTracking().Include(s => s.GanjoorMetre).Where(s => s.PoemId == id && s.SectionType == PoemSectionType.WholePoem).OrderBy(s => s.Index).ToArrayAsync(); + + foreach (var section in sections) + { + section.Top6RelatedSections = (await GetRelatedSections(section.PoemId, section.Index, 0, 6)).Result; + } + + return new RServiceResult(sections); }