private ISet <MediaInstance> GetFilteredMedia(SearchMediaData searchMedia, DbSet <MediaInstance> mediaInstances) { var favoriteMediaFilter = new FavoriteMediaFilter(searchMedia.UserId); var filteredMedia = favoriteMediaFilter.Filter(mediaInstances.ToList().AsReadOnly()) .ToHashSet(); return(filteredMedia); }
protected override IEnumerable <MediaInstanceDto> Handle(GetFavoriteMediaQuery request) { var mediaInstances = _context.MediaInstances .Include(mi => mi.FavoriteMedia) .Include(x => x.MediaTags) .ThenInclude(x => x.Tag) .ToList() .AsReadOnly(); var filter = new FavoriteMediaFilter(request.UserId); var filteredMedia = filter.Filter(mediaInstances) .Select(mi => new MediaInstanceDto(mi.Id, mi.DataType, mi.MediaTags.Select(mt => mt.Tag.Name)) ); return(filteredMedia); }