Exemplo n.º 1
0
        public PokemonViewModel(Main main, List<PowerLevel> levels, List<Category> categories, List<Pokemon> pokemon, List<SpecialAttack> specialAttacks, List<StandardAttack> standardAttacks, List<UserName> users)
            : this()
        {
            this.AddDate = main.AddDate;
            this.EvolvedFrom = main.EvolvedFrom;
            this.Height = main.Height;
            this.HeightCategoryId = main.HeightCategory;
            this.Id = main.Id;
            this.PokemonId = main.PokemonId;
            this.SpecialAttack = main.SpecialAttack;
            this.StandardAttack = main.StandardAttack;
            this.TrainerLevelCaught = main.TrainerLevelCaught;
            this.Weight = main.Weight;
            this.WeightCategoryId = main.WeightCategory;
            this.XId = main.XId;
            this.PowerLevels = levels;

            this.PowerLevel = levels.Single(x => x.Id == levels.Max(y => y.Id));

            _categories = categories;
            _pokemon = pokemon;
            _specialAttacks = specialAttacks;
            _standardAttacks = standardAttacks;
            _users = users;
        }
Exemplo n.º 2
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();
            }
        }