-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b22a359
commit 791bebc
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using ScreenSound04.Modelos; | ||
|
||
namespace ScreenSound04.Filtros; | ||
internal class Linqfilter | ||
{ | ||
public static void FiltrarTodosOsGenerosMusicais(List<Musica> musicas) | ||
{ | ||
var todosOsGenerosMusicais = musicas.Select(generos => generos.Genero).Distinct().ToList(); | ||
foreach (var genero in todosOsGenerosMusicais) | ||
{ | ||
Console.WriteLine($"-{genero}"); | ||
} | ||
} | ||
|
||
public static void FiltrarArtistasPorGeneroMusical(List<Musica> musicas, string genero) | ||
{ | ||
var artistasPorGeneroMusical = musicas.Where(musica => musica.Genero!.Contains(genero)).Select(musica => musica.Artista).Distinct().ToList(); | ||
Console.WriteLine($"Exibindo os artistas por gênero musical >>>{genero}"); | ||
foreach (var artista in artistasPorGeneroMusical) | ||
{ | ||
Console.WriteLine($"-{artista}"); | ||
} | ||
} | ||
public static void FiltrarMusicasDeUmArtista(List<Musica> musicas, string nomeDoArtista) | ||
{ | ||
var musicasDoArtista = musicas.Where(musica => musica.Artista!.Equals(nomeDoArtista)).ToList(); | ||
Console.WriteLine(nomeDoArtista); | ||
foreach (var musica in musicasDoArtista) | ||
{ | ||
Console.WriteLine($"-{musica.Nome}"); | ||
} | ||
} | ||
|
||
internal static void FiltrarMusicasEmCSharp(List<Musica> musicas) | ||
{ | ||
var musicasEmCSharp = musicas | ||
.Where(musica => musica.Tonalidade.Equals("C#")) | ||
.Select(musica => musica.Nome) | ||
.ToList(); | ||
Console.WriteLine("Músicas em C#:"); | ||
foreach (var musica in musicasEmCSharp) | ||
{ | ||
Console.WriteLine($"- {musica}"); | ||
} | ||
} | ||
} | ||
|