Beispiel #1
0
 public async Task <HeroAbilityStat> LookupHeroAbilityStat(int heroId, int abilityId)
 {
     using (var db = new Dota2HeroStatsDB())
     {
         return(await db.HeroAbilityStats.FindAsync(heroId, abilityId));
     }
 }
Beispiel #2
0
 public async Task <Ability> LookupAbility(int abilityId)
 {
     using (var db = new Dota2HeroStatsDB())
     {
         return(await db.Abilities.FindAsync(abilityId));
     }
 }
Beispiel #3
0
        public async Task <Hero> LookupHero(int heroId)
        {
            Hero hero = null;

            using (var db = new Dota2HeroStatsDB())
            {
                hero = await db.Heroes.AsNoTracking().FirstOrDefaultAsync(h => h.HeroId == heroId);
            }
            return(hero);
        }
Beispiel #4
0
        public async Task <Role> LookupRoleByName(string stringRole)
        {
            Role role = null;

            using (var db = new Dota2HeroStatsDB())
            {
                role = await db.Roles.AsNoTracking().FirstOrDefaultAsync(r => r.Name == stringRole);
            }
            return(role);
        }
Beispiel #5
0
        private bool ClaimIdIsValid(string value)
        {
            string steamId = value.Replace("https://steamcommunity.com/openid/id/", "");

            using (var db = new Dota2HeroStatsDB())
            {
                var admin = db.Admins.Find(steamId);
                if (admin == null)
                {
                    return(false);
                }
                return(true);
            }
        }
Beispiel #6
0
 public async Task UpdateEntity <T>(T entity) where T : class, IEntity
 {
     using (var db = new Dota2HeroStatsDB())
     {
         //db.Set<T>().Add(entity);
         db.Set <T>().Attach(entity);
         foreach (DbEntityEntry <IEntity> entry in db.ChangeTracker.Entries <IEntity>())
         {
             IEntity currEntity = entry.Entity;
             entry.State = GetEntityState(currEntity.EntityState);
         }
         try
         {
             await db.SaveChangesAsync();
         }
         catch (DbUpdateException e)
         {
             throw new DataSourceException("Error Updating item in database.", e);
         }
     }
 }