Example #1
0
        public void AddPokemon(PokemonViewModel model)
        {
            using (PokemonGoContext context = new PokemonGoContext())
            {
                Main main = new Main();
                main.AddDate = DateTime.Now;
                main.EvolvedFrom = model.EvolvedFrom;
                main.Height = model.Height;
                main.HeightCategory = model.HeightCategoryId;
                main.PokemonId = model.PokemonId;
                main.SpecialAttack = model.SpecialAttack;
                main.StandardAttack = model.StandardAttack;
                main.TrainerLevelCaught = model.TrainerLevelCaught;
                main.Weight = model.Weight;
                main.WeightCategory = model.WeightCategoryId;
                main.XId = model.XId;
                main.UserId = model.UserId;
                context.Add(main);
                context.SaveChanges();

                PowerLevel level = new PowerLevel();
                level.AddDate = DateTime.Now;
                level.CP = model.PowerLevel.CP;
                level.HP = model.PowerLevel.HP;
                level.MainId = main.Id;
                level.PowerPercent = model.PowerLevel.PowerPercent;
                level.PowerUpDust = model.PowerLevel.PowerUpDust;
                level.TrainerLevel = model.PowerLevel.TrainerLevel;
                context.Add(level);
                context.SaveChanges();
            }
        }
Example #2
0
 public bool AddPowerLevel(PowerLevel power)
 {
     using (PokemonGoContext context = new PokemonGoContext())
     {
         context.Add(power);
         context.SaveChanges();
         return true;
     }
 }
        public ActionResult Power(PowerLevel power)
        {
            try
            {
                PokemonService service = new PokemonService();
                service.AddPowerLevel(power);
                Main main = service.GetPokemon(power.MainId);

                return RedirectToAction("Index", new { id = main.XId });
            }
            catch
            {
                return View();
            }
        }