private async Task AddCharacters(IEnumerable <Character> characters)
 {
     using (var dbContext = new ItsOnlyHeroesContext())
     {
         dbContext.Character.AddRange(characters);
         await dbContext.SaveChangesAsync();
     }
 }
        public async Task <IEnumerable <ItemType> > GetAllItemTypesAsync()
        {
            using (var context = new ItsOnlyHeroesContext())
            {
                var itemTypes = await context.ItemType.ToListAsync();

                return(itemTypes);
            }
        }
        public async Task <IEnumerable <Character> > GetCharactersBasicInfo(List <long> characterIds)
        {
            using (var dbContext = new ItsOnlyHeroesContext())
            {
                var characters = await dbContext.Character
                                 .Where(c => characterIds.Contains(c.CharacterId))
                                 .ToListAsync();

                return(characters);
            }
        }
        public async Task <IEnumerable <Item> > GetAllItemsAsync()
        {
            using (var context = new ItsOnlyHeroesContext())
            {
                var items = await context.Item.Where(x => x.Active == true)
                            .Include(x => x.ItemType)
                            .Include(x => x.Stats)
                            .Include(x => x.BuyCurrency)
                            .ToListAsync();

                return(items);
            }
        }
        public async Task <IEnumerable <Character> > GetCharactersDetailedInfo(List <long> characterIds)
        {
            using (var dbContext = new ItsOnlyHeroesContext())
            {
                var characters = await dbContext.Character
                                 .Where(c => characterIds.Contains(c.CharacterId))
                                 .Include(c => c.Experience)
                                 .Include(c => c.Equipment.Select(e => e.Item))
                                 .ToListAsync();

                return(characters);
            }
        }
        public async Task <Item> GetItemAsync(long itemId)
        {
            using (var context = new ItsOnlyHeroesContext())
            {
                var items = await context.Item.Where(x => x.Active == true)
                            .Where(x => x.ItemId == itemId)
                            .Include(x => x.ItemType)
                            .Include(x => x.Stats)
                            .Include(x => x.BuyCurrency)
                            .FirstOrDefaultAsync();

                return(items);
            }
        }
 public SecurityData()
 {
     _dBContext = new ItsOnlyHeroesContext();
 }