示例#1
0
        public bool SaveCompletedGame(CompletedGame game)
        {
            if (!_db.Players.Any(p => p.Id == game.WinnerId) || !_db.Players.Any(p => p.Id == game.LoserId) ||
                _db.CompletedGames.Any(g => g.Id == game.Id))
            {
                return(false);
            }

            _db.CompletedGames.Add(game);
            _db.SaveChanges();
            return(true);
        }
        public Dictionary <string, CompletedGame> _GetSampleCompletedGames(List <Player> players)
        {
            var game = new CompletedGame()
            {
                Id = "7c26bdcc-b355-4259-98bc-419553ec289e"
            };

            game.Winner      = players[0].Id;
            game.WinnerScore = 21;
            game.Loser       = players[1].Id;
            var dictionary = new Dictionary <string, CompletedGame>();

            dictionary.Add(game.Id, game);
            return(dictionary);
        }
示例#3
0
 public async Task <bool> PutCompletedGame([FromBody] CompletedGame game)
 {
     return(await Task.Run(() => _data.SaveCompletedGame(game)));
 }