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.
17 lines
714 B
17 lines
714 B
using ErsatzTV.Infrastructure.Data; |
|
using ErsatzTV.Infrastructure.Extensions; |
|
using Microsoft.EntityFrameworkCore; |
|
|
|
namespace ErsatzTV.Application.MediaCollections; |
|
|
|
public class GetPlaylistByIdHandler(IDbContextFactory<TvContext> dbContextFactory) |
|
: IRequestHandler<GetPlaylistById, Option<PlaylistViewModel>> |
|
{ |
|
public async Task<Option<PlaylistViewModel>> Handle(GetPlaylistById request, CancellationToken cancellationToken) |
|
{ |
|
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken); |
|
return await dbContext.Playlists |
|
.SelectOneAsync(b => b.Id, b => b.Id == request.PlaylistId) |
|
.MapT(Mapper.ProjectToViewModel); |
|
} |
|
}
|
|
|