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.
22 lines
901 B
22 lines
901 B
using ErsatzTV.Application.MediaItems; |
|
using ErsatzTV.Core.Interfaces.Repositories; |
|
using static ErsatzTV.Application.MediaItems.Mapper; |
|
|
|
namespace ErsatzTV.Application.Artists; |
|
|
|
public class GetAllArtistsHandler : IRequestHandler<GetAllArtists, List<NamedMediaItemViewModel>> |
|
{ |
|
private readonly IArtistRepository _artistRepository; |
|
|
|
public GetAllArtistsHandler(IArtistRepository artistRepository) => _artistRepository = artistRepository; |
|
|
|
public Task<List<NamedMediaItemViewModel>> Handle( |
|
GetAllArtists request, |
|
CancellationToken cancellationToken) => |
|
_artistRepository.GetAllArtists() |
|
.Map( |
|
list => list.Filter( |
|
a => !string.IsNullOrWhiteSpace( |
|
a.ArtistMetadata.HeadOrNone().Match(am => am.Title, () => string.Empty)))) |
|
.Map(list => list.Map(ProjectToViewModel).ToList()); |
|
}
|
|
|