Ejemplo n.º 1
0
 public List <HeroDb> GetAllHeroes()
 {
     using (SomeDotesDbContext db = new SomeDotesDbContext())
     {
         return(db
                .Heroes
                .ToList());
     }
 }
Ejemplo n.º 2
0
 public long GetLastAddedMatch()
 {
     using (SomeDotesDbContext db = new SomeDotesDbContext())
     {
         return(db
                .Results
                .LastOrDefault()
                .MatchId);
     }
 }
Ejemplo n.º 3
0
        public void AddRangeJSONToDatabase(List <Result> results)
        {
            using (SomeDotesDbContext db = new SomeDotesDbContext())
            {
                db
                .Results
                .AddRange(results);

                db.SaveChanges();
            }
        }
Ejemplo n.º 4
0
        public void AddJSONToDatabase(Result result)
        {
            using (SomeDotesDbContext db = new SomeDotesDbContext())
            {
                db
                .Results
                .Add(result);

                db.SaveChanges();
            }
        }
Ejemplo n.º 5
0
        public List <HeroWinPercentageHelper> GetAllHeroesWinChance()
        {
            Dictionary <int, HeroWinPercentageHelper> allHeroesWinChange = new Dictionary <int, HeroWinPercentageHelper>();

            using (SomeDotesDbContext db = new SomeDotesDbContext())
            {
                var tempList = db.Players.Select(p => new
                {
                    p.HeroId,
                    p.PlayerSlot,
                    p.Result.RadiantWin
                });

                foreach (var currentPlayer in tempList)
                {
                    var currentHeroId = currentPlayer.HeroId;

                    if (!allHeroesWinChange.Keys.Contains(currentHeroId))
                    {
                        allHeroesWinChange.Add(currentHeroId, new HeroWinPercentageHelper());
                        allHeroesWinChange[currentHeroId].HeroId = currentHeroId;
                    }

                    if ((currentPlayer.PlayerSlot < 50 && currentPlayer.RadiantWin) || (currentPlayer.PlayerSlot > 50 && !currentPlayer.RadiantWin))
                    {
                        allHeroesWinChange[currentHeroId].Wins++;
                    }
                    else
                    {
                        allHeroesWinChange[currentHeroId].Losses++;
                    }
                }

                var keys = new List <int>(allHeroesWinChange.Keys);

                foreach (var key in keys)
                {
                    allHeroesWinChange[key].WinChance = Math.Round((decimal)((decimal)allHeroesWinChange[key].Wins * 100 / (decimal)(allHeroesWinChange[key].Wins + allHeroesWinChange[key].Losses)), 2);
                }

                return(new List <HeroWinPercentageHelper>(allHeroesWinChange.Values));
            }
        }