Esempio n. 1
0
        public void UpdateBasePokemon(PokemonViewModel pkmnVM)
        {
            PokemonBase pkmn = _dataContext.PokemonBases.FirstOrDefault(x => x.PokemonId == pkmnVM.PokemonId);

                _dataContext.Attach(pkmn);

                pkmn.Name = pkmnVM.Name;
                pkmn.EvoLevel = pkmnVM.EvoLevel;
                pkmn.AbilityOne = pkmnVM.AbilityOne;
                pkmn.AbilityTwo = pkmnVM.AbilityTwo;
                pkmn.AbilityThree = pkmnVM.AbilityThree;
                pkmn.MaleGenderPercent = pkmnVM.MaleGenderPercent;
                pkmn.PrimaryType = pkmnVM.PrimaryType;
                pkmn.SubType = pkmnVM.Subtype;
                pkmn.HPStat = pkmnVM.HPStat;
                pkmn.AttackStat = pkmnVM.AttackStat;
                pkmn.DefenseStat = pkmnVM.DefenseStat;
                pkmn.SpAttackStat = pkmnVM.SpAttackStat;
                pkmn.SpDefenseStat = pkmnVM.SpDefenseStat;
                pkmn.SpeedStat = pkmnVM.SpeedStat;
                pkmn.LevelSpeed = pkmnVM.LevelSpeed;
                pkmn.BaseExp = pkmnVM.BaseExp;
                pkmn.BaseCatch = pkmnVM.BaseCatch;

                try
                {
                    _dataContext.SaveChanges();
                }
                catch (Exception ex)
                {
                    throw new Exception("Could not save changes {0}", ex);
                }
        }
Esempio n. 2
0
 public ActionResult SaveBasePokemon(PokemonViewModel pokemonViewModel)
 {
     try
     {
         repo.UpdateBasePokemon(pokemonViewModel);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.InnerException);
     }
     return null;
 }