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; |
|
|
|
namespace ErsatzTV.Application.MediaCards.Queries |
|
{ |
|
public class |
|
GetTelevisionShowCardsHandler : IRequestHandler<GetTelevisionShowCards, TelevisionShowCardResultsViewModel> |
|
{ |
|
private readonly ITelevisionRepository _televisionRepository; |
|
|
|
public GetTelevisionShowCardsHandler(ITelevisionRepository televisionRepository) => |
|
_televisionRepository = televisionRepository; |
|
|
|
public async Task<TelevisionShowCardResultsViewModel> Handle( |
|
GetTelevisionShowCards request, |
|
CancellationToken cancellationToken) |
|
{ |
|
int count = await _televisionRepository.GetShowCount(); |
|
|
|
List<TelevisionShowCardViewModel> results = await _televisionRepository |
|
.GetPagedShows(request.PageNumber, request.PageSize) |
|
.Map(list => list.Map(ProjectToViewModel).ToList()); |
|
|
|
return new TelevisionShowCardResultsViewModel(count, results); |
|
} |
|
} |
|
}
|
|
|