public async Task <PokemonSkill> Get(int id)
 {
     using (var db = Db)
     {
         var pokemonSkillRepository = new PokemonSkillRepository(db);
         return(await pokemonSkillRepository.FindOneById(id));
     }
 }
 public async Task <IList <PokemonSkill> > GetAll()
 {
     using (var db = Db)
     {
         var pokemonSkillRepository = new PokemonSkillRepository(db);
         return(await pokemonSkillRepository.GetAll());
     }
 }
        public async void Delete(int id)
        {
            using (var db = Db)
            {
                var pokemonSkillRepository = new PokemonSkillRepository(db);
                var pokemonSkill           = await pokemonSkillRepository.FindOneById(id);

                pokemonSkillRepository.Delete(pokemonSkill);
            }
        }
Beispiel #4
0
        private async Task <List <PokemonSkill> > GetPokemonSkills(int id, PokedexContext db)
        {
            var pokemonToPokemonSkillRepository = new PokemonToPokemonSkillRepository(db);
            var task = await pokemonToPokemonSkillRepository.GetByPokemonId(id);

            var results = task.Select(x => x.PokemonSkillId);

            var pokemonSkillRepository = new PokemonSkillRepository(db);
            var task2 = await pokemonSkillRepository.GetAll();

            return(task2.Where(x => results.Contains(x.Id)).ToList());
        }
        public async void Update(List <PokemonSkill> values)
        {
            using (var db = Db)
            {
                var pokemonSkillRepository = new PokemonSkillRepository(db);

                foreach (var value in values)
                {
                    var pokemonType = await pokemonSkillRepository.FindOneById(value.Id);

                    pokemonType.Name = value.Name;

                    pokemonSkillRepository.Update(value);
                }
            }
        }
        public async void Insert(List <PokemonSkill> values)
        {
            using (var db = Db)
            {
                var pokemonSkillRepository = new PokemonSkillRepository(db);

                foreach (var value in values)
                {
                    var pokemonSkill = await pokemonSkillRepository.FindOneByAttribute(value);

                    if (pokemonSkill.Count.Equals(0))
                    {
                        pokemonSkillRepository.Insert(value);
                    }
                    else
                    {
                        // Log error for DuplicateException Id or Name already exists in table
                    }
                }
            }
        }