* clean up genre, tag, studio orphans * enforce foreign keys at connection level * wip * fix fragment scroll offset * fix see all link for music videos * add fake artist metadata * not null artist id * add artist scanning * remove improperly named music videos * code cleanup * add artists to search results and collections * clean up music video metadata / artist * add artist view * show music videos on artist page * add music video artwork placeholder
34 lines
1.2 KiB
C#
34 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using ErsatzTV.Core.Interfaces.Repositories;
|
|
using LanguageExt;
|
|
using MediatR;
|
|
using static ErsatzTV.Application.MediaCards.Mapper;
|
|
using static LanguageExt.Prelude;
|
|
|
|
namespace ErsatzTV.Application.MediaCards.Queries
|
|
{
|
|
public class GetMusicVideoCardsHandler : IRequestHandler<GetMusicVideoCards, MusicVideoCardResultsViewModel>
|
|
{
|
|
private readonly IMusicVideoRepository _musicVideoRepository;
|
|
|
|
public GetMusicVideoCardsHandler(IMusicVideoRepository musicVideoRepository) =>
|
|
_musicVideoRepository = musicVideoRepository;
|
|
|
|
public async Task<MusicVideoCardResultsViewModel> Handle(
|
|
GetMusicVideoCards request,
|
|
CancellationToken cancellationToken)
|
|
{
|
|
int count = await _musicVideoRepository.GetMusicVideoCount(request.ArtistId);
|
|
|
|
List<MusicVideoCardViewModel> results = await _musicVideoRepository
|
|
.GetPagedMusicVideos(request.ArtistId, request.PageNumber, request.PageSize)
|
|
.Map(list => list.Map(ProjectToViewModel).ToList());
|
|
|
|
return new MusicVideoCardResultsViewModel(count, results, None);
|
|
}
|
|
}
|
|
}
|