Exemplo n.º 1
0
 public Move GetMoveByName(string name)
 {
     using (var context = new PokeContext())
     {
         var move = context.Moves.FirstOrDefault(p => p.Name == name);
         return move;
     }
 }
Exemplo n.º 2
0
 public IEnumerable<Move> GetMoves()
 {
     using (var context = new PokeContext())
     {
         var moves = context.Moves.ToList();
         return moves;
     }
 }
Exemplo n.º 3
0
 public Move GetMoveById(int id)
 {
     using (var context = new PokeContext())
     {
         var move = context.Moves.Find(id);
         return move;
     }
 }
Exemplo n.º 4
0
 public void DeleteAllPokemon()
 {
     using (var context = new PokeContext())
     {
         var allPokemon = context.Pokemon;
         context.Pokemon.RemoveRange(allPokemon);
         context.SaveChanges();
     }
 }
Exemplo n.º 5
0
 public void DeleteAllMoves()
 {
     using (var context = new PokeContext())
     {
         var allMoves = context.Moves;
         context.Moves.RemoveRange(allMoves);
         context.SaveChanges();
     }
 }
Exemplo n.º 6
0
 public bool addPokemonMoveRelationship(int level, string moveName, string pokemonName)
 {
     if (moveName == null || pokemonName == null || level <= 0)
         return false;
     using (var context = new PokeContext())
     {
         var pokemon = context.Pokemon.FirstOrDefault(p => p.Name == pokemonName);
         var move = context.Moves.FirstOrDefault(m => m.Name == moveName);
         if (move == null || pokemon == null) return false;
         var pokemon_move = new Pokemon_Moves
         {
             MoveId = move.MoveId,
             PokemonId = pokemon.PokeId,
             Level = level
         };
         context.Pokemon_Moves.Add(pokemon_move);
         return SaveContextChanges(context);
     }
 }
Exemplo n.º 7
0
 public IEnumerable<Move> GetMovesByPokemon(string name)
 {
     using (var context = new PokeContext())
     {
         var pokemon = context.Pokemon.FirstOrDefault(p => p.Name == name);
         IEnumerable<Move> data = null;
         try
         {
             data = context.Pokemon_Moves
                 .Join(context.Moves, pm => pm.MoveId, m => m.MoveId, (pm, m) => new { PM = pm, M = m })
                 .Where(selection => selection.PM.PokemonId == pokemon.PokeId).Select(final => final.M)
                 .ToList();
         }
         catch (Exception ex)
         {
             Console.WriteLine("No Data available");
         }
         return data;
     }
 }
Exemplo n.º 8
0
 public IEnumerable<Move> GetMovesByType(string type)
 {
     using (var context = new PokeContext())
     {
         var moves = context.Moves.Where(m => m.Type == type).OrderByDescending(m => m.Power).ToList();
         return moves;
     }
 }