This commit is contained in:
Hamid Reza Mohammadi 2023-12-16 18:01:03 +03:30
parent d7600ffeab
commit abc448e52e

View File

@ -377,6 +377,8 @@ namespace RMuseum.Services.Implementation
1 + await context.GanjoorQuotedPoems.AsNoTracking().Where(p => p.PoemId == poem1.Id && p.RelatedPoemId == poem2.Id).CountAsync() : 1
};
//first couplet:
tagIndex = dbPage.HtmlText.IndexOf("<p>", tagIndex);
if (tagIndex != -1 && tagIndex < closeTagIndex)
@ -539,6 +541,17 @@ namespace RMuseum.Services.Implementation
context.Add(relatedPoem);
await context.SaveChangesAsync();
if (relatedPoem.SamePoemsQuotedCount > 1)
{
var allRelateds = await context.GanjoorQuotedPoems.Where(p => p.Id != relatedPoem.Id && p.PoemId == relatedPoem.PoemId && p.RelatedPoemId == relatedPoem.RelatedPoemId).ToListAsync();
foreach (var rel in allRelateds)
{
rel.SamePoemsQuotedCount = relatedPoem.SamePoemsQuotedCount;
}
context.UpdateRange(allRelateds);
await context.SaveChangesAsync();
}
var poet1Cat = await context.GanjoorCategories.AsNoTracking().Where(c => c.PoetId == poem1Poet.Id && c.ParentId == null).SingleAsync();
GanjoorQuotedPoem reverseRelation = new GanjoorQuotedPoem()
{
@ -576,6 +589,17 @@ namespace RMuseum.Services.Implementation
context.Add(reverseRelation);
await context.SaveChangesAsync();
if (reverseRelation.SamePoemsQuotedCount > 1)
{
var allRelateds = await context.GanjoorQuotedPoems.Where(p => p.Id != reverseRelation.Id && p.PoemId == reverseRelation.PoemId && p.RelatedPoemId == reverseRelation.RelatedPoemId).ToListAsync();
foreach (var rel in allRelateds)
{
rel.SamePoemsQuotedCount = reverseRelation.SamePoemsQuotedCount;
}
context.UpdateRange(allRelateds);
await context.SaveChangesAsync();
}
index = dbPage.HtmlText.IndexOf("<li>", tagIndex);
}
return new RServiceResult<bool>(true);