mirror of https://github.com/ErsatzTV/ErsatzTV.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
840 B
23 lines
840 B
using ErsatzTV.Core.Domain; |
|
using ErsatzTV.Infrastructure.Data; |
|
using Microsoft.EntityFrameworkCore; |
|
|
|
namespace ErsatzTV.Application.MediaCollections; |
|
|
|
public class GetAllPlaylistGroupsHandler(IDbContextFactory<TvContext> dbContextFactory) |
|
: IRequestHandler<GetAllPlaylistGroups, List<PlaylistGroupViewModel>> |
|
{ |
|
public async Task<List<PlaylistGroupViewModel>> Handle( |
|
GetAllPlaylistGroups request, |
|
CancellationToken cancellationToken) |
|
{ |
|
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken); |
|
|
|
List<PlaylistGroup> playlistGroups = await dbContext.PlaylistGroups |
|
.AsNoTracking() |
|
.Include(g => g.Playlists) |
|
.ToListAsync(cancellationToken); |
|
|
|
return playlistGroups.Map(Mapper.ProjectToViewModel).ToList(); |
|
} |
|
}
|
|
|