Exemplo n.º 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();
            }
        }
Exemplo n.º 2
0
        public ActionResult Evolve(int mainId)
        {
            PokemonService service = new Services.PokemonService();

            Main ancestor = service.GetPokemon(mainId);

            PokemonViewModel viewModel = new PokemonViewModel(service.GetCategories(), service.GetPokemon(), service.GetSpecialAttacks(), service.GetStandardAttacks(), service.GetUsers());
            viewModel.EvolvedFrom = ancestor.XId;

            return View("Index", viewModel);
        }
Exemplo n.º 3
0
        public ActionResult Index(PokemonViewModel viewModel)
        {
            try
            {
                PokemonService service = new PokemonService();
                service.AddPokemon(viewModel);

                //return RedirectToAction("Index", new { id = viewModel.XId });
                return RedirectToAction("Index");
            }
            catch (Exception ex)
            {
                return View();
            }
        }
Exemplo n.º 4
0
        public ActionResult Index(Guid? id)
        {
            PokemonService service = new Services.PokemonService();
            PokemonViewModel viewModel = new PokemonViewModel();

            if (id.HasValue)
            {
                Main main = service.GetPokemon(id.Value);
                List<PowerLevel> powerLevels = service.GetPowerLevels(main.Id);
                viewModel = new PokemonViewModel(main, powerLevels, service.GetCategories(), service.GetPokemon(), service.GetSpecialAttacks(), service.GetStandardAttacks(), service.GetUsers());
            }
            else
            {
                viewModel = new PokemonViewModel(service.GetCategories(), service.GetPokemon(), service.GetSpecialAttacks(), service.GetStandardAttacks(), service.GetUsers());
            }

            return View(viewModel);
        }