From eca2bc48f1fe27df50b14ae8017c0a6a4ffcb590 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Mon, 2 May 2022 19:53:52 +0430 Subject: [PATCH] docs: #312 bug fix: Pages with more than one first whole poem sections or having paragraphs have problems in the related poems section --- GanjooRazor/Pages/Index.cshtml.cs | 24 ++++++++++++++------ GanjooRazor/Pages/_GanjoorPagePartial.cshtml | 1 + 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/GanjooRazor/Pages/Index.cshtml.cs b/GanjooRazor/Pages/Index.cshtml.cs index 63bbac18..a3b7c221 100644 --- a/GanjooRazor/Pages/Index.cshtml.cs +++ b/GanjooRazor/Pages/Index.cshtml.cs @@ -550,6 +550,8 @@ namespace GanjooRazor.Pages } } + public bool MutiPartPoemPage { get; set; } + public List SectionsWithRelated { get; set; } public List SectionsWithMetreAndRhymes { get; set; } @@ -557,15 +559,23 @@ namespace GanjooRazor.Pages { SectionsWithRelated = new List(); SectionsWithMetreAndRhymes = new List(); - foreach (var section in GanjoorPage.Poem.Sections) + MutiPartPoemPage = GanjoorPage.Poem.Verses.Where(v => v.VersePosition == VersePosition.Paragraph || v.VersePosition == VersePosition.Single).Any() + || + GanjoorPage.Poem.Sections.Count(s => s.SectionType == PoemSectionType.WholePoem && s.VerseType == VersePoemSectionType.First) != 1; + if ( + !MutiPartPoemPage + ) { - if(section.Top6RelatedSections.Length > 0) + foreach (var section in GanjoorPage.Poem.Sections) { - SectionsWithRelated.Add(section); - } - if(section.SectionType == PoemSectionType.WholePoem && section.GanjoorMetre != null && !string.IsNullOrEmpty(section.RhymeLetters)) - { - SectionsWithMetreAndRhymes.Add(section); + if (section.Top6RelatedSections.Length > 0) + { + SectionsWithRelated.Add(section); + } + if (section.SectionType == PoemSectionType.WholePoem && section.GanjoorMetre != null && !string.IsNullOrEmpty(section.RhymeLetters)) + { + SectionsWithMetreAndRhymes.Add(section); + } } } } diff --git a/GanjooRazor/Pages/_GanjoorPagePartial.cshtml b/GanjooRazor/Pages/_GanjoorPagePartial.cshtml index fc066907..a068f081 100644 --- a/GanjooRazor/Pages/_GanjoorPagePartial.cshtml +++ b/GanjooRazor/Pages/_GanjoorPagePartial.cshtml @@ -302,6 +302,7 @@ @if (Model.GanjoorPage.Poem.Sections.Where(s => s.SectionType == RMuseum.Models.Ganjoor.PoemSectionType.WholePoem && s.GanjoorMetre != null).Any() || !string.IsNullOrEmpty(Model.GanjoorPage.Poem.OldTag) || !string.IsNullOrEmpty(Model.GanjoorPage.Poem.SourceName)) { + @if(!Model.MutiPartPoemPage) @foreach (var s in Model.GanjoorPage.Poem.Sections.Where(s => s.SectionType == RMuseum.Models.Ganjoor.PoemSectionType.WholePoem && s.GanjoorMetre != null).ToList()) {