예제 #1
0
 public GameEngine(Session session, GameBoard gameBoard, GameLog gameLog, LudoContext context)
 {
     this.Session   = session;
     this.GameBoard = gameBoard;
     this.gameLog   = gameLog;
     this.context   = context;
 }
예제 #2
0
        public void RemoveFromDb(LudoContext context)
        {
            context = new LudoContext();

            if (context.Session.Any(s => s.SessionId == this.SessionId))
            {
                context.Session.Remove(this);
            }

            context.SaveChanges();
        }
예제 #3
0
        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);
        }
예제 #4
0
        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();
        }
예제 #5
0
        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();
        }