Beispiel #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();
            }
        }
Beispiel #2
0
 public List<Category> GetCategories()
 {
     using (PokemonGoContext context = new PokemonGoContext())
     {
         return context.Categories.OrderBy(x => x.Name).ToList();
     }
 }
Beispiel #3
0
        public List<Detail> GetDetails(int id)
        {
            using (PokemonGoContext context = new PokemonGoContext())
            {
                List<Detail> details = (from m in context.Mains
                                        join p in context.Pokemons on m.PokemonId equals p.Id
                                        join hc in context.Categories on m.HeightCategory equals hc.Id
                                        join wc in context.Categories on m.WeightCategory equals wc.Id
                                        join st in context.StandardAttacks on m.StandardAttack equals st.Id
                                        join sp in context.SpecialAttacks on m.SpecialAttack equals sp.Id
                                        join pl in context.PowerLevels on m.Id equals pl.MainId
                                        where m.PokemonId == id
                                        orderby pl.PowerUpDust descending,
                                        pl.PowerPercent descending,
                                        pl.CP descending
                                        select new Detail
                                        {
                                            AddDate = pl.AddDate,
                                            EvolvedFrom = m.EvolvedFrom,
                                            Height = m.Height,
                                            HeightCategory = m.HeightCategory,
                                            HeightCategoryDisplay = hc.Name,
                                            Id = m.Id,
                                            PokemonId = m.PokemonId,
                                            PokemonName = p.Name,
                                            SpecialAttack = m.SpecialAttack,
                                            SpecialAttackDisplay = sp.Name,
                                            StandardAttack = m.StandardAttack,
                                            StandardAttackDisplay = st.Name,
                                            Weight = m.Weight,
                                            WeightCategory = m.WeightCategory,
                                            WeightCategoryDisplay = wc.Name,
                                            XId = m.XId,
                                            CP = pl.CP,
                                            HP = pl.HP,
                                            PowerLevelId = pl.Id,
                                            MainId = m.Id,
                                            PowerPercent = pl.PowerPercent,
                                            PowerUpDust = pl.PowerUpDust,
                                            TrainerLevel = pl.TrainerLevel,
                                            TrainerLevelCaught = m.TrainerLevelCaught
                                        }).ToList();

                foreach(Detail detail in details)
                {
                    if(detail.WeightCategory == 1)
                    {
                        detail.WeightCategoryDisplay = String.Empty;
                    }

                    if(detail.HeightCategory == 1)
                    {
                        detail.HeightCategoryDisplay = String.Empty;
                    }
                }

                return details;
            }
        }
Beispiel #4
0
 public bool AddPowerLevel(PowerLevel power)
 {
     using (PokemonGoContext context = new PokemonGoContext())
     {
         context.Add(power);
         context.SaveChanges();
         return true;
     }
 }
Beispiel #5
0
 public List<UserName> GetUsers()
 {
     using (PokemonGoContext context = new PokemonGoContext())
     {
         return context.Users.OrderBy(x => x.Name).ToList();
     }
 }
Beispiel #6
0
 public List<StandardAttack> GetStandardAttacks()
 {
     using (PokemonGoContext context = new PokemonGoContext())
     {
         return context.StandardAttacks.OrderBy(x => x.Name).ToList();
     }
 }
Beispiel #7
0
 public List<PowerLevel> GetPowerLevels(int mainId)
 {
     using (PokemonGoContext context = new PokemonGoContext())
     {
         return context.PowerLevels.Where(x => x.MainId == mainId).ToList();
     }
 }
Beispiel #8
0
 public List<Pokemon> GetPokemon()
 {
     using (PokemonGoContext context = new PokemonGoContext())
     {
         return context.Pokemons.OrderBy(x => x.Name).ToList();
     }
 }
Beispiel #9
0
 public Main GetPokemon(int id)
 {
     using (PokemonGoContext context = new PokemonGoContext())
     {
         return context.Mains.Single(x => x.Id == id);
     }
 }
Beispiel #10
0
 public Main GetPokemon(Guid xId)
 {
     using (PokemonGoContext context = new PokemonGoContext())
     {
         return context.Mains.Single(x => x.XId == xId);
     }
 }