Ejemplo n.º 1
0
        private void CreateBoggleBoxInDb(BoggleBox boggleBox)
        {
            var board = new Board()
            {
                BoggleBoxId = boggleBox.BoggleBoxId,
                Letters     = boggleBox.Dice.GetLetters()
            };

            using (var context = new BoggleDbContext())
            {
                // Checks if board already exist
                if (context.Board.Count(b => b.BoggleBoxId == boggleBox.BoggleBoxId) != 0)
                {
                    return;
                }

                try
                {
                    context.Board.Add(board);
                    context.SaveChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
            }
        }
Ejemplo n.º 2
0
 private Board GetBoardById(Guid boggleBoxId)
 {
     using (var context = new BoggleDbContext())
     {
         return((from board in context.Board
                 where board.BoggleBoxId == boggleBoxId
                 select board).FirstOrDefault());
     }
 }
Ejemplo n.º 3
0
        public void CreateGame(Game game)
        {
            var boggleGame = new BoggleGame()
            {
                Name           = game.Name,
                Score          = game.Score,
                fk_BoggleBoxId = Guid.Parse(game.BoggleBoxId)
            };

            using (var context = new BoggleDbContext())
            {
                context.BoggleGame.Add(boggleGame);
                context.SaveChanges();
            }
        }
Ejemplo n.º 4
0
        public List <PlayerScore> GetHighscores()
        {
            using (var context = new BoggleDbContext())
            {
                var playerScores = (from game in context.BoggleGame
                                    select new PlayerScore()
                {
                    PlayerName = game.Name,
                    Score = game.Score,
                    BoggleBoxId = game.fk_BoggleBoxId
                }).ToList();

                var highscores = playerScores.OrderByDescending(p => p.Score).Take(15).ToList();

                return(highscores);
            }
        }
Ejemplo n.º 5
0
 public WordController(BoggleDbContext context)
 {
     this.context = context;
 }
Ejemplo n.º 6
0
 public HighscoreController(BoggleDbContext context)
 {
     _context = context;
 }