public IEnumerable <AlbumResource> FilterAlbums(IEnumerable <AlbumResource> albums, int metadataProfileId) { var metadataProfile = _metadataProfileService.Exists(metadataProfileId) ? _metadataProfileService.Get(metadataProfileId) : _metadataProfileService.All().First(); var primaryTypes = new HashSet <string>(metadataProfile.PrimaryAlbumTypes.Where(s => s.Allowed).Select(s => s.PrimaryAlbumType.Name)); var secondaryTypes = new HashSet <string>(metadataProfile.SecondaryAlbumTypes.Where(s => s.Allowed).Select(s => s.SecondaryAlbumType.Name)); var releaseStatuses = new HashSet <string>(metadataProfile.ReleaseStatuses.Where(s => s.Allowed).Select(s => s.ReleaseStatus.Name)); return(albums.Where(album => primaryTypes.Contains(album.Type) && ((!album.SecondaryTypes.Any() && secondaryTypes.Contains("Studio")) || album.SecondaryTypes.Any(x => secondaryTypes.Contains(x))) && album.ReleaseStatuses.Any(x => releaseStatuses.Contains(x)))); }
private List <MetadataProfileResource> GetAll() { var profiles = _profileService.All().ToResource(); return(profiles); }