Exemple #1
0
 private void filter()
 {
     //If all are blank then get all pokemon
     if (region == " " &&
         type == " " &&
         type2 == " ")
     {
         dgPokedexList.ItemsSource = _pokemonManager.RetrieveAllPokemon();
         RefreshList();
         return;
     }
     //If all are not blank
     else if (region != " " &&
              type != " " &&
              type2 != " ")
     {
         dgPokedexList.ItemsSource = _pokemonManager.RetrievePokemonByTypeType2AndRegion(region,
                                                                                         type, type2);
         RefreshList();
         return;
     }
     //If region is blank
     else if (region == " " &&
              type != " " &&
              type2 != " ")
     {
         dgPokedexList.ItemsSource = _pokemonManager.RetrievePokemonByTypeAndType2(type, type2);
         RefreshList();
         return;
     }
     //If type is not blank
     else if (region != " " &&
              type != " " &&
              type2 == " ")
     {
         dgPokedexList.ItemsSource = _pokemonManager.RetrievePokemonByRegionAndType(region, type);
         RefreshList();
         return;
     }
     //If region and type 2 are not blank
     else if (region != " " &&
              type == " " &&
              type2 != " ")
     {
         dgPokedexList.ItemsSource = _pokemonManager.RetrievePokemonByRegionAndType2(region, type2);
         RefreshList();
         return;
     }
     //If region is not blank
     else if (region != " " &&
              type == " " &&
              type2 == " ")
     {
         dgPokedexList.ItemsSource = _pokemonManager.RetrievePokemonByRegion(region);
         RefreshList();
         return;
     }
     //If type is not null
     else if (region == " " &&
              type != " " &&
              type2 == " ")
     {
         dgPokedexList.ItemsSource = _pokemonManager.RetrievePokemonByType(type);
         RefreshList();
         return;
     }
     //If type 2 is not blank only
     else if (region == " " &&
              type == " " &&
              type2 != " ")
     {
         dgPokedexList.ItemsSource = _pokemonManager.RetrievePokemonByType2(type2);
         RefreshList();
         return;
     }
     else
     {
         //User should not be able to get here, but just in case
         MessageBox.Show("No results found, please try again");
     }
 }