docs: #306 adding related sections to poem sections

This commit is contained in:
Hamid Reza Mohammadi 2022-04-14 12:29:01 +04:30
parent 009375f127
commit de9cb0b07c
3 changed files with 23 additions and 4 deletions

View File

@ -1,4 +1,6 @@
namespace RMuseum.Models.Ganjoor
using System.ComponentModel.DataAnnotations.Schema;
namespace RMuseum.Models.Ganjoor
{
/// <summary>
/// Ganjoor Poem Section
@ -77,5 +79,11 @@
/// verses text as html (ganjoor.net format)
/// </summary>
public string HtmlText { get; set; }
/// <summary>
/// top 6 related sections
/// </summary>
[NotMapped]
public GanjoorCachedRelatedSection[] Top6RelatedSections { get; set; }
}
}

View File

@ -6899,6 +6899,11 @@
verses text as html (ganjoor.net format)
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.GanjoorPoemSection.Top6RelatedSections">
<summary>
top 6 related sections
</summary>
</member>
<member name="T:RMuseum.Models.Ganjoor.GanjoorPoemTranslation">
<summary>
poem translation

View File

@ -645,9 +645,15 @@ namespace RMuseum.Services.Implementation
/// <returns></returns>
public async Task<RServiceResult<GanjoorPoemSection[]>> GetPoemWholeSections(int id)
{
return new RServiceResult<GanjoorPoemSection[]>(
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<GanjoorPoemSection[]>(sections);
}