adding rootCatId to poet view model
This commit is contained in:
parent
27c029da51
commit
21d0ff822f
@ -24,5 +24,10 @@
|
||||
/// urlslug
|
||||
/// </summary>
|
||||
public string FullUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// root cat id
|
||||
/// </summary>
|
||||
public int RootCatId { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -3597,6 +3597,11 @@
|
||||
urlslug
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoetViewModel.RootCatId">
|
||||
<summary>
|
||||
root cat id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:RMuseum.Models.Ganjoor.ViewModels.GanjoorVerseViewModel">
|
||||
<summary>
|
||||
Ganjoor Verse View Model
|
||||
|
||||
@ -34,21 +34,24 @@ namespace RMuseum.Services.Implementation
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var res = await _context.GanjoorPoets
|
||||
.Where(p => !websitePoets || p.Id < 200)
|
||||
.OrderBy(p => p.Name) //it seems that current version of ef core does not handle this => OrderBy(p => p.Name, StringComparer.Create(new CultureInfo("fa-IR"), true))
|
||||
.Select
|
||||
(
|
||||
p => new GanjoorPoetViewModel()
|
||||
{
|
||||
Id = p.Id,
|
||||
Name = p.Name,
|
||||
Description = p.Description,
|
||||
FullUrl = _context.GanjoorCategories.Where(c => c.PoetId == p.Id && c.ParentId == null).Single().FullUrl
|
||||
}
|
||||
)
|
||||
.ToListAsync();
|
||||
var res =
|
||||
await
|
||||
(from poet in _context.GanjoorPoets
|
||||
join cat in _context.GanjoorCategories.Where(c => c.ParentId == null)
|
||||
on poet.Id equals cat.PoetId
|
||||
where !websitePoets || poet.Id < 200
|
||||
orderby poet.Name descending
|
||||
select new GanjoorPoetViewModel()
|
||||
{
|
||||
Id = poet.Id,
|
||||
Name = poet.Name,
|
||||
Description = poet.Description,
|
||||
FullUrl = cat.FullUrl,
|
||||
RootCatId = cat.Id
|
||||
}
|
||||
)
|
||||
.ToListAsync();
|
||||
|
||||
StringComparer fa = StringComparer.Create(new CultureInfo("fa-IR"), true);
|
||||
res.Sort((a, b) => fa.Compare(a.Name, b.Name));
|
||||
|
||||
@ -150,7 +153,8 @@ namespace RMuseum.Services.Implementation
|
||||
Id = p.Id,
|
||||
Name = p.Name,
|
||||
Description = p.Description,
|
||||
FullUrl = _context.GanjoorCategories.Where(c => c.PoetId == p.Id && c.ParentId == null).Single().FullUrl
|
||||
FullUrl = _context.GanjoorCategories.Where(c => c.PoetId == p.Id && c.ParentId == null).Single().FullUrl,
|
||||
RootCatId = _context.GanjoorCategories.Where(c => c.PoetId == p.Id && c.ParentId == null).Single().Id
|
||||
}) .FirstOrDefaultAsync(),
|
||||
Cat = catViewModel
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user