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.
33 lines
1.2 KiB
33 lines
1.2 KiB
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); |
|
} |
|
} |
|
}
|
|
|