You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.2 KiB
45 lines
1.2 KiB
using DataBase.Context;
|
|
using DataBase.Entity;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace DataBase.DataManager
|
|
{
|
|
public partial class DbDataManager
|
|
{
|
|
public async Task AddGame(Game game)
|
|
{
|
|
using (var context = new PongDbContext())
|
|
{
|
|
await context.Games.AddAsync(game);
|
|
}
|
|
}
|
|
|
|
public Task<bool> RemoveGame(int id)
|
|
{
|
|
using (var context = new PongDbContext())
|
|
{
|
|
var game = context.Games.Where(g => g.gameId == id).ToList().FirstOrDefault();
|
|
if (game != null)
|
|
{
|
|
var result = context.Games.Remove(game);
|
|
return Task.FromResult(result != null);
|
|
}
|
|
return Task.FromResult(false);
|
|
}
|
|
}
|
|
|
|
public Task<Game> GetGame(int id)
|
|
{
|
|
using (var context = new PongDbContext())
|
|
{
|
|
var game = context.Games.Where(g => g.gameId == id).ToList().FirstOrDefault();
|
|
return Task.FromResult<Game>(game);
|
|
}
|
|
}
|
|
}
|
|
}
|