Files
ersatztv/ErsatzTV.Application/MediaCollections/Queries/GetPlaylistTreeHandler.cs
T
Jason DoveandGitHub 867c88d8fc add trakt playlist option (#2171)
* add generate playlist option; add system playlists

* fix official lists; sync items to playlist
2025-07-19 16:56:25 +00:00

27 lines
900 B
C#

using ErsatzTV.Application.Tree;
using ErsatzTV.Core.Domain;
using ErsatzTV.Infrastructure.Data;
using Microsoft.EntityFrameworkCore;
namespace ErsatzTV.Application.MediaCollections;
public class GetPlaylistTreeHandler(IDbContextFactory<TvContext> dbContextFactory)
: IRequestHandler<GetPlaylistTree, TreeViewModel>
{
public async Task<TreeViewModel> Handle(
GetPlaylistTree request,
CancellationToken cancellationToken)
{
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken);
List<PlaylistGroup> playlistGroups = await dbContext.PlaylistGroups
.AsNoTracking()
.OrderByDescending(pg => pg.IsSystem)
.ThenBy(pg => pg.Name)
.Include(g => g.Playlists)
.ToListAsync(cancellationToken);
return Mapper.ProjectToViewModel(playlistGroups);
}
}