Move mapping assignment to Map

This commit is contained in:
Lampan-git 2025-03-05 22:37:18 +01:00
parent e137a06362
commit 7abb94d8a2

View File

@ -43,18 +43,6 @@ public class PeopleRepository(IDbContextFactory<JellyfinDbContext> dbProvider, I
if (!filter.ItemId.IsEmpty()) if (!filter.ItemId.IsEmpty())
{ {
dbQuery = dbQuery.Include(p => p.BaseItems!.Where(m => m.ItemId == filter.ItemId)); dbQuery = dbQuery.Include(p => p.BaseItems!.Where(m => m.ItemId == filter.ItemId));
return dbQuery
.AsEnumerable()
.Select(p =>
{
var personInfo = Map(p);
var mapping = p.BaseItems?.FirstOrDefault();
personInfo.Role = mapping?.Role;
personInfo.SortOrder = mapping?.SortOrder;
return personInfo;
})
.ToArray();
} }
return dbQuery.AsEnumerable().Select(Map).ToArray(); return dbQuery.AsEnumerable().Select(Map).ToArray();
@ -111,10 +99,13 @@ public class PeopleRepository(IDbContextFactory<JellyfinDbContext> dbProvider, I
private PersonInfo Map(People people) private PersonInfo Map(People people)
{ {
var mapping = people.BaseItems?.FirstOrDefault();
var personInfo = new PersonInfo() var personInfo = new PersonInfo()
{ {
Id = people.Id, Id = people.Id,
Name = people.Name, Name = people.Name,
Role = mapping?.Role,
SortOrder = mapping?.SortOrder
}; };
if (Enum.TryParse<PersonKind>(people.PersonType, out var kind)) if (Enum.TryParse<PersonKind>(people.PersonType, out var kind))
{ {