Exemplo n.º 1
0
        public static async void ImportSmallHeroIcons()
        {
            var apiHero = new Dota2Results();

            using (var db = new ApplicationContext())
            {
                var dbHeroes = db.Heroes.ToList();
                var id       = 0;
                foreach (var dbHero in dbHeroes)
                {
                    id++;
                    var byteResult = await apiHero.HeroImage(dbHero.ValveHeroName, 0);

                    //var heroImage = new HeroesImages
                    //{

                    //    Blob = byteResult,
                    //    HeroId = dbHero.Id,
                    //    Id = id
                    //};
                    //db.HeroImage.Add(heroImage);
                    Console.WriteLine("Added {0} image", dbHero.Name);
                }
                db.SaveChanges();
            }
        }
Exemplo n.º 2
0
        public async Task <JsonResult> GetHeroes()
        {
            var apiRepo = new Dota2Results();
            var results = await apiRepo.GetHores();

            return(Json(results, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        public async Task <JsonResult> GetMatchHistor(string accountId)
        {
            var api     = new Dota2Results();
            var history = await api.GetMatchHistory(accountId);



            return(Json(history, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
        public static void ImportHeroes()
        {
            var apiRepo      = new Dota2Results();
            var heroesResult = apiRepo.GetHores().Result;

            using (var ctx = new ApplicationContext())
            {
                foreach (var hero in heroesResult.Heroes)
                {
                    var herEntity = new WebApiRepository.Models.Heroes
                    {
                        Id            = hero.Id,
                        Name          = hero.Name,
                        ValveHeroName = hero.ValveName
                    };

                    Console.WriteLine("Saving -> {0}", hero.Name);

                    ctx.Heroes.Add(herEntity);
                }
                ctx.SaveChanges();
            }
        }
Exemplo n.º 5
0
        public static async void ImportDotaItems()
        {
            var apiItems = new Dota2Results();
            var items    = await apiItems.GetItems();

            using (var db = new ApplicationContext())
            {
                foreach (var item in items)
                {
                    var newItems = new GameItems
                    {
                        Id               = item.Id,
                        Cost             = item.Cost,
                        LocalizedName    = item.LocalizedName,
                        DotaBuffItemName = item.LocalizedName.ToLower().Replace(" ", "-"),
                        IsRecipe         = item.IsRecipe
                    };
                    Console.WriteLine("Adding ->{0}", item.LocalizedName);
                    db.GameItems.Add(newItems);
                }

                db.SaveChanges();
            }
        }
Exemplo n.º 6
0
 public StatsController(DotaBuffParser dotaBuff, Dota2Results api)
 {
     _dotaBuff = dotaBuff;
     _api      = api;
 }