public GameEngine(Session session, GameBoard gameBoard, GameLog gameLog, LudoContext context) { this.Session = session; this.GameBoard = gameBoard; this.gameLog = gameLog; this.context = context; }
public void RemoveFromDb(LudoContext context) { context = new LudoContext(); if (context.Session.Any(s => s.SessionId == this.SessionId)) { context.Session.Remove(this); } context.SaveChanges(); }
public async Task <Session> LoadSessionAsync(LudoContext context) { Session session = null; context = new LudoContext(); session = await context.Session .Include(s => s.Players) .ThenInclude(p => p.GamePieces) .FirstOrDefaultAsync(); context.SaveChanges(); return(session); }
public async Task AddToDb(LudoContext context) { context = new LudoContext(); //If exists do update instead if (context.GameLog.Any(gl => gl.GameLogId == this.GameLogId)) { context.GameLog.Update(this); } else { context.GameLog.Add(this); } await context.SaveChangesAsync(); }
public async Task AddToDbAsync(LudoContext context) { context = new LudoContext(); //If exists do update instead if (context.Session.Any(s => s.SessionId == this.SessionId)) { context.Session.Update(this); } else { context.Session.Add(this); } await context.SaveChangesAsync(); }