#59 fullurl + fulltitle for pages related to poems

This commit is contained in:
Hamid Reza Mohammadi 2021-01-04 16:02:07 +03:30
parent d571c28152
commit 1fa79772ba

View File

@ -946,21 +946,30 @@ namespace RMuseum.Services.Implementation
}
}
await _context.SaveChangesAsync();
var orphanPages = await _context.GanjoorPages.Where(p => p.ParentId != null && p.FullUrl == null).ToListAsync();
var orphanPages = await _context.GanjoorPages.Include(p => p.Poem).Where(p => p.FullUrl == null).ToListAsync();
foreach(var page in orphanPages)
{
string fullUrl = page.UrlSlug;
string fullTitle = page.Title;
GanjoorPage parent = await _context.GanjoorPages.Where(p => p.Id == page.ParentId).SingleAsync();
while(parent != null)
if(page.GanjoorPageType == GanjoorPageType.PoemPage)
{
fullUrl = parent.UrlSlug + "/" + fullUrl;
fullTitle = parent.Title + " » " + fullTitle;
parent = parent.ParentId == null ? null : await _context.GanjoorPages.Where(p => p.Id == parent.ParentId).SingleAsync();
fullTitle = page.Poem.FullTitle;
fullUrl = page.Poem.FullUrl;
}
else
if(page.ParentId != null)
{
GanjoorPage parent = await _context.GanjoorPages.Where(p => p.Id == page.ParentId).SingleAsync();
while (parent != null)
{
fullUrl = parent.UrlSlug + "/" + fullUrl;
fullTitle = parent.Title + " » " + fullTitle;
parent = parent.ParentId == null ? null : await _context.GanjoorPages.Where(p => p.Id == parent.ParentId).SingleAsync();
}
}
page.FullUrl = fullUrl;
page.FullTitle = fullTitle;