Ejemplo n.º 1
0
        public async Task RemoveAsync(int id)
        {
            var player = await GetAsync(id);

            using (var db = new FootballBotDbContext(_options))
            {
                db.Players.Remove(player);
                await db.SaveChangesAsync();
            }
        }
Ejemplo n.º 2
0
        public async Task UpdateAsync(Player player)
        {
            if (player == null || player.Id == default(int))
            {
                return;
            }

            using (var db = new FootballBotDbContext(_options))
            {
                db.Entry(player).State = EntityState.Modified;
                await db.SaveChangesAsync();
            }
        }
Ejemplo n.º 3
0
        public async Task AddAsync(Player player)
        {
            if (player == null)
            {
                return;
            }

            using (var db = new FootballBotDbContext(_options))
            {
                db.Players.Add(player);
                await db.SaveChangesAsync();
            }
        }
Ejemplo n.º 4
0
        public async Task UpdateMultipleAsync(IEnumerable <Player> players)
        {
            if (!players.Any())
            {
                return;
            }

            using (var db = new FootballBotDbContext(_options))
            {
                foreach (var player in players)
                {
                    db.Entry(player).State = EntityState.Modified;
                }

                await db.SaveChangesAsync();
            }
        }