✏️ Fix typo
continuous-integration/drone/push Build is passing Details

pull/110/head
Alexis Drai 2 years ago
parent 6c03fc4586
commit 90c1eba43b

@ -34,7 +34,7 @@ namespace App
// DB stuff when the app opens
// Later, we'll use a GameDBRunner
using (PlayerDBManager playerDBManager = new(new DiceAppDbContext()))
using (PlayerDbManager playerDBManager = new(new DiceAppDbContext()))
{
// get all the players from the DB
IEnumerable<PlayerEntity> entities = playerDBManager.GetAll();
@ -147,7 +147,7 @@ namespace App
}
// DB stuff when the app closes
using (PlayerDBManager playerDBManager = new(new DiceAppDbContext()))
using (PlayerDbManager playerDBManager = new(new DiceAppDbContext()))
{
// get all the players from the app's memory
IEnumerable<Player> models = gameRunner.GlobalPlayerManager.GetAll();

@ -3,10 +3,10 @@ using Model;
namespace Data.EF.Players
{
public sealed class PlayerDBManager : IManager<PlayerEntity>, IDisposable
public sealed class PlayerDbManager : IManager<PlayerEntity>, IDisposable
{
private readonly DiceAppDbContext db;
public PlayerDBManager(DiceAppDbContext db)
public PlayerDbManager(DiceAppDbContext db)
{
this.db = db;
}

@ -0,0 +1,56 @@
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Model;
namespace Data.EF.Players
{
public sealed class PlayerDbManager : IManager<PlayerEntity>, IDisposable
{
private readonly DiceAppDbContext db;
public PlayerDbManager(DiceAppDbContext db)
{
this.db = db;
}
public void Dispose()
{
db.Dispose();
}
public PlayerEntity Add(PlayerEntity toAdd)
{
if (db.Players!.Where(entity => entity.Name == toAdd.Name).Any())
{
throw new ArgumentException("this username is already taken", nameof(toAdd));
}
EntityEntry ee = db.Players!.Add(toAdd);
db.SaveChanges();
return (PlayerEntity)ee.Entity;
}
public IEnumerable<PlayerEntity> GetAll()
{
return db.Players!.AsEnumerable();
}
public PlayerEntity GetOneByName(string name)
{
throw new NotImplementedException();
}
public void Remove(PlayerEntity toRemove)
{
throw new NotImplementedException();
}
public PlayerEntity Update(PlayerEntity before, PlayerEntity after)
{
throw new NotImplementedException();
}
public PlayerEntity GetOneByID(Guid ID)
{
throw new NotImplementedException();
}
}
}
Loading…
Cancel
Save